#LeetCode 2657, Find the Prefix Common Array of Two Arrays, just using a #HashSet for this, nothing too crazy. Could have also used #BitMasking, which was well given the problem constraints, a pretty easy medium problem tonight #JS#CompetitiveProgramming
#LeetCode 2540, Minimum Common Value, given two sorted arrays & needing to find the smallest value included inside of both arrays, I made a quick one-liner with JS find & lodash's sortedIndexOf. #BinarySearch to quickly check if an nums1 value is present in nums2, -1 if not #JS
#LeetCode 1306 Jump Game 3 recursive depth first search DFS one liner marking visited jumped to indices as negative for prev visit checks, bounds check to make sure I don't jump outside the given array lmao, and returning the reachability of zero for given start indices #JS
@LeetCode has upgraded its AI time & space complexity analysis; they now check your approach, the main idea of how your solutions solve the problem, and even grade your work. All these stats after solving problems is why #LeetCode is fun #JS#Strings#SlidingWindow#Simulation
#LeetCode 761, recursively checking each inner string segment for special binary strings. Then, sorting those in reverse descending order, until at the end returning the lexicographically largest special binary string after a bunch of swaps for those inner segments. #JS
#LeetCode 693, two liner using a trick where an alternating bit sequence XOR with itself >> 1 will become all bits set to 1. Numbers with all bits set to 1 AND itself plus 1 will equal zero. For example, (1010^0101)=1111, 1111+1 = 10000, 1111&10000 = 0 #JS#Bitwse#Math
#LeetCode 401, iterating through all numbers up to 10 bits in length. Then, calculating minute & hour amounts using bitwise operators, then if the bitcount of the number is perfect, I push a string to my answer array, then return it all, any order #JS#Bitwise
#LeetCode 190 reversing some bits, we can do this easily one-liner style to convert to a string, reverse, and convert back to a number. Or we can use bitwise tricks to swap around binary segments, divide and conquer style, without even needing to use recursion #JS#Bitwise
#LeetCode 1382, using divide & conquer to height balance a given binary search tree. Since it's already a BST input, we can inorder traversal & push root.val's to an array along the way, automatically getting a sorted array in the process #BinaryTree#JS#divideandconquer
#LeetCode 1458, very easy hard. Pretty similar to longest common subsequence, we pick whether or not to choose a pair of elements to multiply together, or one array to skip an element in, with initial state as -Infinity and just math max everything together #JS#DP#Daily
#LeetCode 3074, the one liner she tells you not to worry about #JS
var minimumBoxes = (apple, capacity) => capacity.sort((a,b)=>b-a).map( (el)=>{psum+=el; return +(psum<ASUM)},psum=0,ASUM = apple.reduce( (sum,el)=>sum+el)).reduce( (sum,el)=> sum+el)+1;
#LeetCode 2054, using two Priority Queues, one ordered by start times, the other with ending times, to sort events. A while loop iterates over valid event pairings to find a max sum of event values for either one big event, or two non overlapping events #JS