Problems


September 4, 2022

Evaluate division

We will first create an adjacency list from the provided equations and values list. Each node will have the related node and thier weight in it. Then we run DFS to find the result. Finally, we will...

Read

September 4, 2022

Populating next right pointers in each node II

We will traverse the tree with BFS and in each level, we will append the nodes to a list. After each level traversal, we take these nodes, and assing the next node to it's right node. We will repeat...

Read

September 4, 2022

Populating next right pointers in each node

We will traverse the tree with BFS and in each level, we will append the nodes to a list. After each level traversal, we take these nodes, and assing the next node to it's right node. We will repeat...

Read

September 4, 2022

Recover binary search tree

We will traverse the tree with inorder traversal and add each nodes to the a list. Then we sort the values of each nodes, then iterate over the sorted values, and assign the values to respective tree...

Read

September 4, 2022

Unique binary search trees II

We will take the top-down approach to solve the problem. We will start from 1 and for every position, we take is as root, and build a tree with the left and right subarray for that root position,...

Read

September 4, 2022

Unique binary search trees

We will take the top-down approach to solve the problem. We will start from 1 and for every position, we take is as root, and build a tree with the left and right subarray for that root position, and...

Read

September 4, 2022

Verify preorder serialization of a binary tree

We will split the string with , as delimeter, and pop the last value from it to check whether it's a # or not, if not, we immediately return false. Then we iterate over the...

Read

September 4, 2022

Vertical order traversal of a binary tree

We will first traverse the tree with DFS and store it's values along with row and column in the the process. Then we sort them by column value and group them by column value. Finally, take all these...

Read

September 3, 2022

Balance a binary search tree

We will first traverse the tree with inorder traversal, and append all the values to an array. Then we create a binary search tree with the values, where root will be the middle of the array, thus we...

Read

September 3, 2022

Decode string

We will use a stack and append the values until we reach ]. Then we pop the values from stack and make a string until we reach [. Then we pop the numbers from the stack and...

Read
... 65 66 67 68 69 ...