Diary
DevGod
#Leetcode 594, already this solved in JS so I decided to brush my rusty Java21 skills. Couldn't remember the Java _.countBy lodashJS eqivlent, so I just went with a binary search aproach instead. While loop to find the last element, then returning max range #Java #programminglife
Read More6/29/2025
DevGod
#Leetcode 1498, Used lodash's builtin binary searching method sortedLastIndex -1 to get the rightmost max number of the array, after sorting the array. Then I use this 2**R-L exponential to get number of subseqs. Used abunch of bigInts to handle large numbers. #JS #WebDev
Read More6/28/2025
DevGod
#Leetcode 2099, easy daily problem, just using a min priority queue, since if we go over the k elements limit, we want to dequeue the smallest element. This leaves us with K largest elements at the end. We then just have to sort and map back to the number using the indexs. #JS
Read More6/27/2025
DevGod
#Leetcode 2311, very messy solution but still works well. Main idea is to build a subseq respecting the 32 bit limit of JS bitwise. We build left to right, then if we run into an invalid subseq we greedily remove ones until it works, while keeping track of count + leading zeros
Read More6/25/2025
DevGod
#Leetcode 2200, an easy daily problem solve using a set() to avoid duplicates, as well as just some min and maxs to prevent the algorithm from going out of bounds. At the end we just convert the hashset back to an array. #Javascript #JS #NodeJS
Read More6/23/2025
DevGod
#Leetcode 2081, I choked on this daily so needed to see the editorial. Thought I would get away with using an OEIS template for finding the palindrome number seq, but just time limited myself on this hard problem. Also whomever wrote the leetcode editorial cheated lmao O(1)
Read More6/22/2025
DevGod
#Leetcode 2138, very easy #Daily problem by just Lodash's builtin chunk function, then editing the last group to have the fill char, then returning the mapped with all char arrays in chunk converted into substrings #Js #Lodash #Coding
Read More6/21/2025
DevGod
#Leetcode 3443, at first struggled cause I thought it was max final ending dist, instead of the max dist at any point by changing K dirs. Used a freq map to keep track of dists, then use 2*k because by cancelling out pairs like 'NS / EW', I can add 2 to my dist #JS #Hashmap
Read More6/19/2025
DevGod
#Leetcode 2294, sorting the given array to do a #Greedy trick without storing noncontinuous subseqs, just ans++ every time we get a diff >= K. We are counting how many 'cuts' we can make in our sorted array, returning cuts+1. #JS #Sorting #Javascript
Read More6/19/2025
DevGod
#Leetcode 2966, Greedily sorting then using lodash chunk function for splitting the array into a matrix of subarrays of length 3. If I find a chunk breaking the rules of a distance greater then K, I return an empty array instead. Else I returned the chunked version of the array
Read More6/17/2025
DevGod
#Leetcode 1432, a sequel to yesterday's problem. The big catch is we can NOT have any leading zeros in our converted Max & Min. Finding Max is the same, change first non 9 digit to 9s. Min is trickier, as we forloop to ensure we dont convert the string to value with leading zeros
Read More6/14/2025
DevGod
#Leetcode 2566, pretty easy problem, just converting the numbers to strings, then max is the first non 9 most significant digit (MSD) replaced all with 9. The min is converting the first MSD to 0 with replace all. Returning the max and min converted back to JS Number #javascript
Read More6/13/2025
DevGod
Leetcode 2616 was super tricky until I finally saw that there was only one greedy way to sort & find the differences of everything to solve the minified maximum pairs rule. I needed was binary search to find the min max of P pairs. Zero pairs = return 0 max :)
Read More6/12/2025
DevGod
Leetcode 2929 Distribute Candies Among Children II. A rare daily solve in PY instead of JS, just for the ease of the builtin comb function. Broke my brain for a while before remembering Inclusion Exclusion Jutsu. Enjoy my messy chicken scratch code.
Read More5/31/2025
DevGod
#Leetcode 909 Snakes and Ladders. Messy spotToCord function to convert a board spot to cords for checking if snake or ladder. Breadth First Search to search for a path to the N^2 while keeping track of the dice rolls needed to get there. Returning either -1 or dice rolls
Read More5/30/2025
DevGod
Leetcode 2359. Solved today's daily using a DFS function to fill my memo matrix with node distances from the root node. I ran this DFS for each given input nodes. Return -1 if no path connection, else return minimal max distance found using memo matrix
Read More