Problems
September 11, 2022
Maximum performance of a team
We will take a queue to store the maximum k number of speed. Then we iterate over the sorted array which we will create by combining efficiency and speed array, push the item to the heap, also count...
ReadSeptember 11, 2022
Minimum falling path sum
We will create a helper function that will calculate the minimum path from the starting row and and column. In the helper function we will check the boundary of the column, if it is out of boundary...
ReadSeptember 10, 2022
Best time to buy and sell stock II
We will create a helper function to calculate the max profit, in each step, we can either buy or if we already bought, then we can sell. And each of these steps, we can either take the item or skip...
ReadSeptember 10, 2022
Island perimeter
We will run a DFS starting from given row and column and get all the nodes that are same color. If a node is not in perimeter of the same color region, the number of adjacent node will be 4 for this...
ReadSeptember 10, 2022
Wildcard matching
We will start from the first character from the beginning of 2 sting, if they match, then we move to the next string, if the character is ?
in p, then also we move to the next string. If...
September 10, 2022
Maximum binary tree II
We will run a simple DFS to find the place and insert the new node there.
Time Complexity: O(n)
Space Complexity: O(n)
September 10, 2022
Coloring a border
We will run a DFS starting from given row and column and get all the nodes that are same color. If a node is not in perimeter of the same color region, the number of adjacent node will be 4 for this...
ReadSeptember 10, 2022
Count and say
As the title says, we just do what the question says. The base-case has already been provided. All we need to do now is to write the recursive calls. The answer to that is provided in the question as...
ReadSeptember 10, 2022
Best time to buy and sell stock III
We will create a helper function to calculate the max profit, in each step, we can either buy or if we already bought, then we can sell. And each of these steps, we can either take the item or skip...
ReadSeptember 10, 2022
Partition array according to given pivot
We will take 3 list, one for less, one for equal and one for more than the pivot value. Then we iterate over the input list, append the value to the respective list. Finally we combine 3 list, and...
Read