(8/8)
- one pass to find the candidate. one pass to verify it actually appears > N/2 times.
- the second pass matters: the problem guarantees a majority exists, but in the general case it might not.
- always verify. not mandatory for lc though.
Day 4 #SDESheetChallenge
3 problems today.
- find repetition
- find repeating and missing
- count inversions
Floyd's cycle detection, math equations and merge sort; you wouldn't expect 'em in simple array problems.
learnings and explanation in thread (1/8)
@takeUforward_
(8/8)
optimal: Modified Merge Sort.
- when merging two sorted halves – if the left element is greater than right, all remaining left elements are too.
- instead of counting one by one, add all of them at once: (mid - left + 1).
- inversion count becomes a byproduct of sorting.
(9/9)
- the gap method feels like magic until you realise it's just shell sort logic across diff arrays.
- you're not merging. you're letting elements trickle into their correct positions through progressively smaller jumps.
- no third array. just math. lc intuition even simpler
Day 3 #SDESheetChallenge
3 problems. felt slightly harder. @striver_79's videos are a daily now – his explanations are something else.
- rotate matrix 90 degrees
- merge overlapping intervals
- merge sorted arrays
learnings and explanation in thread (1/9)
@takeUforward_