Problems


October 13, 2022

Find positive integer solution for a given equation

Given a function f(x, y) and a value z, return all positive integer pairs x and y where f(x,y) == z. Rephrase the problem...

Read

October 12, 2022

Determine whether matrix can be obtained by rotation

We will rotate the matrix 4 times and check if it is equal to the target matrix. Time complexity: O(n^2) Space complexity: O(n^2)

Read

October 12, 2022

Largest perimeter triangle

We will sort the array in descending order and check if the sum of the first three numbers is greater than the sum of the next three numbers. If it is, we return the sum of the first three numbers....

Read

October 11, 2022

Number of recent calls

We will use a queue to store the recent calls. We will remove the calls that are not in the range of 3000ms. Then we will return the size of the queue. Time complexity: O(n) Space complexity: O(n)

Read

October 11, 2022

Increasing triplet subsequence

We will keep track of the smallest and second smallest number in the array. If we find a number that is greater than both, we return true. Otherwise, we return false. Time Complexity:...

Read

October 10, 2022

Break a palindrome

We can check the half of the string and if a character is not a, we can replace it with a. If all characters are a, we can replace the last character with b. If the string is a single character, we...

Read

October 9, 2022

Guess number higher or lower

This is a classic binary search problem. We will use binary search to find the number. We will use provided guess function to check whether the number is equal to the target or not....

Read

October 9, 2022

Find bottom left tree value

We will traverse the tree with BFS and assign the first node of the each level in our result. At the end of the traversal, we will return the result, which will store the left most value of the last...

Read

October 9, 2022

Convert bst to greater tree

We will iterate over the tree in reverse inorder and keep track of the sum of all the nodes we have traversed so far. We will add the sum to the current node and update the sum with the current node...

Read

October 9, 2022

Two sum IV input is a bst

This is very similar to two sum problem. But rather than traversing an array, we will traverse a tree. We will be using DFS to traverse the tree and along with the way, we will store the difference...

Read
... 49 50 51 52 53 ...