Problems


September 16, 2022

Finding pairs with a certain sum

We will create 2 counter for both nums1 and nums2 and also we will keep track of nums2. Every time we add something, we increase the value in nums2, and update the counter. The for count, we will...

Read

September 16, 2022

Design an atm machine

We will store all the notes to an array, which will be the attribute of the class. We will also have a lookup notes dictionary. For deposit, we will just increase the number of bank notes in the ATM...

Read

September 15, 2022

Find original array from doubled array

We will first count the number of elements in the changed array. Then we will look for 0. If the count of 0 is odd, we return empty array, else we add half of them in our result. Then we sort the...

Read

September 15, 2022

Validate ip address

We will split the string with . and :. If the number of chunk is not 4 for ipv4 or not 8 for ipv6, we return Neither. Otherwise, we check check separately, for ipv4, each...

Read

September 14, 2022

Insufficient nodes in root to leaf paths

We will traverse the node with DFS and each time we reach a leaf node, we check for the insufficient node, if the node is insufficient, we delete it from the tree. After traversal of whole tree, we...

Read

September 14, 2022

Pseudo palindromic paths in a binary tree

We will start from root and traverse the root with DFS. In the process we will count the occureance of each node's value. Whenever we reach a root node, we will check for pseudo palindrome, if found...

Read

September 14, 2022

Spiral matrix II

First we will initialize the matrix with 0 value in all of it's position. Then we will determine the value of left, right, top and bottom. Then we assing the value k from the top row to our matrix,...

Read

September 13, 2022

Range sum query immutable

We will store the nums as a class property and each time there is a query, we sum up the range in between and return the result. Time Complexity: O(n) Space Complexity:...

Read

September 13, 2022

UTF-8 validation

We will follow the problem statement and assume everything is correct and move forward. We will use a try-except statement if anything goes wrong and will return false from the except statement....

Read

September 13, 2022

Reorder data in log files

We will create two different array, one for the letter logs and another for the digits logs. Then we iterate over all the logs and separate them. Then we sort the letters log, first by the content,...

Read
... 56 57 58 59 60 ...