Implement a method to validate a fantasy lineup and return true/false: the sum of player salary cannot exceed the contest's max salary cap; any single player can only be used once; the lineup cannot contain more than the required number of players; no more than 3 players on a single team; the lineup must encompass at least two games; all roster positions listed in the contest must be filled.
Asked in the phone screen stage. Use validate_lineup(lineup, players, contest). lineup contains {playerId, position} objects, players contains {playerId, teamId, name, salary} objects, and contest contains salaryCap, positionsRequired, and games, where each game has gameId and teamIds. Return a boolean.
def validate_lineup(lineup, players, contest):