qwertyboss

The only difference between ordinary and extraordinary is just that little "extra".

Law 16/48

Once you have gained a certain level of respect temporary withdrawal will make you more admired.

LC: 165. Compare Version Numbers

If version1 < version2, return -1.
If version1 > version2, return 1.
Otherwise, return 0.

Input: version1 = "1.0", version2 = "1.0.0"
Output: 0

πŸ§‘πŸ»β€πŸ’» LC 169. Majority Element

Given an array num of size n, return the majority element. The majority element is the element that appears more than ⌊n / 2βŒ‹ times.

Input: nums = [2,2,1,1,1,2,2]
Output: 2

The difficulty was in solving it in linear time O(n) and constant space O(1).
Solution: Use Boyer-Moore Voting Algorithm, choose a candidate element and +1 if same -1 if different if 0 then change candidate element.