DriveReady

P02 — Counting — every solution explained

This lesson is part of full access

One payment of ₹250 opens every lesson, practice set and mock for all five companies. No subscription, no expiry.

What is inside

  • 1. Character frequency map, insertion-ordered
  • 2. Most frequent character; ties -> earliest in the string
  • 3. Does any character repeat?
  • 4. Elements appearing exactly once, in first-seen order
  • 5. How many DISTINCT values occur an odd number of times. (This is REV-001's reported "distinct after removing pairs".)
  • 6. The single element appearing once when all others appear twice. XOR trick
  • 7. First repeating element (earliest SECOND occurrence), else Integer.MIN_VALUE
  • 8. Do two arrays contain the same multiset of values?
  • 9. Highest frequency among all values
  • 10. Words occurring more than once, in first-seen order, case-insensitive
  • 11. Can the characters be rearranged into a palindrome?
  • 12. Difference between the highest and lowest frequency present
  • 13. Values occurring more than n/k times (k=3 -> "majority-ish")
  • -