FunctionRacerProblemsRace

Cheer Board

HardClassesPython, JavaScript, TypeScript, Java, C++

Implement a class CheerBoard that keeps score at a talent show. The crowd cheers and boos the acts, and the host wants to know at any time who is in front and who is last. Write these methods:

The tests call the methods in sequence and compare every return value. The expected list holds null for the constructor.

Example 1

CheerBoard()
cheer("bo")
cheer("ada")
cheer("bo")
get_leader() returns "bo"
get_trailer() returns "ada"
boo("ada")
get_trailer() returns "bo"
cheer("cy")
get_trailer() returns "cy"
points_of("ada") returns 0

After three cheers bo has 2 points and ada has 1. A boo takes ada off the board, so bo is both leader and trailer. Then cy joins with 1 point and becomes the trailer.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Classes problems