Somal
BAN USER1. Generate HM which tells at each hour, which movies could be played.
2. In a loop till no hours are left, start with the hour which has 1 movie only.
3. For that particular movie, remove it's name for all the timings it can be played.
4. continue this for next time (which has 1 inlet only : that is which can play only one movie)
O(m) space : m no. of times which can be played.
O(n) time : no. of inputs
1.O(n2) solution
->For each number, start from end checking if it's A[i] + 1 and greater than the max difference found till then, if so ..update it....
2.O(n) solution with O(n) memory
->Use HashMap to store all numbers and its indices.
->In second array traversal, for each number, check if map contains A[i] + 1, and update max difference.
We can use Observer pattern here.
Every cell will have all the dependents list. Once the cell undergoes changes, it will go through each element of its dependent list and update that. If those dependents have more dependents, we could continue solve this using DFS approach.
O(n^2) Solution... with O(1) space...
1. Sort the array.
2. For each element nums[i], perform TwoSum search by calling twoSum(nums,i+1, nums.length, target-nums[i])
3. You might want to use HashMapList to avoid adding duplicate triplets.
TwoSum on sorted array:
1. Take 2 pointers, start and end.
2. if(tar
- Somal February 25, 2018