As reported: PayPal Karat technical screen (2025): one coding question, the "singable" problem below.
A singer can perform a song only if every note of the song lies within the singer's range, from their lowest to their highest note (inclusive).
A note is a pitch letter followed by an octave digit, e.g. "C5". Pitches from lowest to highest are C D E F G A B; octaves go from 0 to 7. A note in a higher octave is always higher; within the same octave, the later letter is higher. The lowest possible note is C0 and the highest B7.
Write singable(song, lowest, highest) that returns whether the singer can sing the song. N is the length of the song.
Example 1
song1 = ["F4","B4","C5"]
singable(song1, "F4", "C5") -> true
singable(song1, "A4", "C5") -> false (F4 is below A4)
Example 2
song2 = ["C3","E3","G3","C4","E4","G4","C5"]
singable(song2, "B2", "C5") -> true
singable(song2, "C3", "B4") -> false (C5 is above B4)
Example 3
song3 = ["B4","F5","B5"]
singable(song3, "B4", "B5") -> true
singable(song3, "B4", "C5") -> false
Example 4
song5 = ["F4"]
singable(song5, "D4", "E4") -> false
Constraints: 1 ≤ N ≤ 10^5; every note is a letter in C D E F G A B followed by a digit 0–7; lowest ≤ highest.
Code runner format: one JSON value per line: song, lowest, highest. The harness prints true or false.