Ctrl K

Whole-Day Shift Pairs

Easy
The list shifts holds the lengths of work shifts in hours. A dispatcher wants to join two different shifts so that together they cover a whole number of days: 24 hours, 48, 72, and so on. Return the number of index pairs i < j for which shifts[i] + shifts[j] is a multiple of 24.
Example 1
shifts=[10, 14, 30, 18, 48] → 2

The pairs 10 + 14 = 24 and 30 + 18 = 48 work. 48 has no partner: its sum with any other shift is not a multiple of 24.

Example 2
shifts=[24, 48, 72] → 3

Every shift is a whole number of days, so all three pairs work.

Example 3
shifts=[5] → 0

With a single shift there are no pairs.

Constraints
  • 1 ≤ len(shifts) ≤ 100
  • 1 ≤ shifts[i] ≤ 10⁹
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsThe Candidate With Most Votes EasyValues One Apart EasyEven Piles of Cards EasyMatching Domino Tiles EasyWords From Letter Tiles Easy
loading Python…
Input
shifts=[10, 14, 30, 18, 48]
Expected
2

Run checks the first 3 tests in your browser. Submit checks all 86 tests on the server, hidden ones included.