Problems


November 22, 2022

Process tasks using servers

We will use two heaps to simulate. The first heap will be a min heap of the servers. The second heap will be a min heap of the tasks. Then, we will iterate through the tasks. If the task is less than...

Read

November 22, 2022

Sort colors

We will use two pointers to keep track of the start and end of the array. Then, we will iterate through the array. If the number is 0, then we will swap the number at the start pointer with the...

Read

November 22, 2022

132 pattern

We will use a stack to store the numbers. Then, we will iterate through the numbers and check if the number is less than the second number. If it is, then we will pop the numbers from the stack until...

Read

November 22, 2022

odd-even-jump

We need to jump higher and lower alternately to the end. Take [5,1,3,4,2] as example. If we start at 2, we can jump either higher first or lower first to the end, because we are already at the end....

Read

November 21, 2022

Camelcase matching

We will create a helper function to check if a string is a subsequence of another string. Then we will iterate over the queries and check if the query is a subsequence of the pattern. If it is, then...

Read

November 21, 2022

Vowel spellchecker

We will use a set to store the words in the wordlist. Then, we will use a dictionary to store the words in the wordlist with the vowels replaced with *. Then, we will iterate through the...

Read

November 21, 2022

Minimum addition to make integer beautiful

We will iterate through the digits of the number and find the minimum number of digits we need to add to make the number beautiful. We will keep track of the number of digits we have seen and the...

Read

November 21, 2022

Linked list in binary tree

We will traverse the tree using DFS and check if the linked list is present in the tree or not. If the linked list is present in the tree, then we will return True. Otherwise, we will...

Read

November 21, 2022

Nearest exit from entrance in maze

We will start from the entrance, run BFS through the matrix and find the nearest exit. If we can't find the exit, we will return -1. Time complexity: O(mn) Space...

Read

November 21, 2022

design linked list

We will use a stack to store the values and then do the operations on the stack.

Read
... 32 33 34 35 36 ...