Check if Two Lists Have Equal Content

Problem Given two integer lists (possibly unsorted), determine whether they hold the same content as multisets — same values with the same counts.

Input / Output

  • Input: two lists. Output: boolean.

Constraints

  • Sizes up to 10^5; O(n) expected via hashing; duplicates must be respected (set comparison is wrong).

Example

  • [1,2,2,3] vs [3,2,1,2] → true; [1,2,2] vs [1,1,2] → false.
asked …
LeaderboardSalaryAccount