Problem 175520 · medium · Phase 01 Prerequisites & Setup

Same Cards, Shuffled

lists · comparison · sorting

Two hands of cards are given as lists. Write same_cards(a, b) that returns True if the two lists contain exactly the same items with the same repetitions, in any order, and False otherwise.

Examples

Input:  a = [1, 2, 2, 3], b = [3, 2, 1, 2]
Output: True

Input:  a = [1, 2, 2], b = [1, 1, 2]
Output: False

Constraints

  • 0 <= len(a), len(b) <= 5000

Goals

  • Decide whether two lists hold the same items regardless of order
  • Account for repeated items correctly
Starting Python…