Problem Given a matrix, find the path from top left to bottom right with the greatest product by moving only down and right. The code is in C++. The only moves allowed are down and right. The solution works for positive numbers. Reference https://www.byte-by-byte.com/matrixproduct/?utm_source=optin_carrot&utm_medium=pdf&utm_campaign=50questions Written with StackEdit. Advertisements
Given an unsorted array, find the length of the longest sequence of consecutive numbers in the array. $ g++ -std=c++11 ./FindLongestSequence.cc $ ./a.out 4 Reference https://www.byte-by-byte.com/consecutivearray Written with StackEdit.
Given an array of integers where each value 1 <= x <= len(array), write a function that finds all the duplicates in the array. C++ Solution $ g++ -std=c++11 ./FindDuplicates.cc $ ./a.out 1 2 Reference https://www.byte-by-byte.com/findduplicates/
The following code has two implementations of finding median of two sorted arrays in O(n) and O(log n). Reference https://www.youtube.com/watch?v=MHNTl_NvOj0 The most lucid explanation of the code.
Premise A hashmap has a time complexity of O(1) for all operations. Problem You have to find a constant time method to uniformly random selection of a key in a Hash map. Assumptions The map can grow to memory size. You can use any readymade hash map. Solution […]