Problems
August 27, 2022
Interval list intersections
We will iterate over both list and check whether we have any overlaps or not, if we have we take the maximum of start time and minimum of end time as the intersection value and append it to our...
ReadAugust 27, 2022
Swap nodes in pairs
We will create a dummy node, and set this as previous node, assing next pointer to head. Then from head, we take 2 nodes each time, swap their positions, then move the current and previous node until...
ReadAugust 26, 2022
Reordered power of 2
We will count the number of digits in out given input. Then we take all the power of 2 from 1 to 32 bit integers, compare the digits of them, if any one of it matches with our given input, we return...
ReadAugust 26, 2022
Minimum number of flips to make the binary string alternating
We will take the string, and start comparing with first character as 0, and count the number of flips required. If we take first character as 1, the number of flips will be length of the string minus...
ReadAugust 25, 2022
Ransom note
We will count each character from magazine, then we iterate over each character of ransom note, check whether it is available in the count, if not immediately return false. If present in the count,...
ReadAugust 25, 2022
Count servers that communicate
We iterate over each row, and check if we have another 1 in the row, then we add both of them in the result count. We do the same thing for column, and iterate over it to find another value for 1 and...
ReadAugust 25, 2022
Compare version numbers
First we split 2 versions with .
and loop over the minimum number of both lenght, check whether one or two is bigger then return immediately. If both are equal, then we check whether we...
August 24, 2022
Rotate list
We will first iterate over the list to count the number of the nodes. Then took k and mod it with the count for mitigate overflow. Then we took 2 pointer, first one we iterate k times and then start...
ReadAugust 24, 2022
Power of three
We will devide the number by 3 until it's 1. If in any step, we have any reminder, we will return false, otherwise return true.
Time Complexity: O(log(n))
Space Complexity:...
August 23, 2022
Palindrome linked list
We will iterate over the whole list, and add the result to an array. Then we check whether the array is palindrome or not and return that value.
Time Complexity: O(n)
Space...