Pacific and Atlantic Water Flow
Calculate water flow from a matrix to the Pacific and Atlantic oceans.
Input: heights = [[2,1],[1,2]]
Output: [[0,0],[0,1],[1,0],[1,1]]
Explanation: All cells can flow to both oceans because water can move to adjacent cells of equal or lower height or directly off the edges.
Sort a String by Frequency
Sort a string by the frequency of its characters.
Input: s = "cccaaa"
Output: "cccaaa" or "aaaccc"
Explanation: Both 'c' and 'a' appear three times, so sorting them by descending frequency keeps them grouped equally.
Find the majority element in an array.
Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊n / 2⌋ times. You may assume that the majority element always exists in the array.
Input: nums = [3, 2, 3]
Output: 3
Explanation: The number 3 appears 2 times, which is strictly greate…