dsa1 min read
Minimum Moves to Equal Array Elements II [Medium] — Median Target
Find the minimum total moves to make all array elements equal by targeting the median value.
Read →
1575 articles
Find the minimum total moves to make all array elements equal by targeting the median value.
Find the longest nested set S(k) in a permutation array by tracing cycles with visited marking in O(n) time.
Rearrange nums to maximize advantage over B using a greedy strategy: assign the smallest winning card, else discard the smallest.
Generate all unique subsets from an array with duplicates by sorting and skipping repeated elements at each recursion level.
Check if string B is a rotation of A by checking if B appears in A+A using a substring search.