Two questions, 90 minutes, not hard.
First question: given a string representing the board of a single-player game laid out horizontally, containing three possible values: '.', 'T', 'C'. '.' means the position is empty, 'C' means there's a coin at that position, and 'T' means the player's token is at that position. The board length is at most 100.
The player has multiple tokens, and the movement rules are as follows: each token can move 3 cells to the right per move. The move must be exactly 3 cells to the right — no other step count, and it can never move left. Each token can move multiple times. If the landing cell is already occupied by another token, that move can't be made. If a token lands on a coin after moving, it collects that coin. Each coin can only be collected once. If a token passes over a cell with a coin during a move without landing on it, it doesn't collect that coin — only the coin on the final landing cell counts. Find the maximum number of coins the player can collect.
Second question: given an array containing several two-digit numbers, with array length at most 100. Group together the two-digit numbers that share a common digit (for example, 55, 58, 25, and 45 all share the digit 5, so they can go in the same group; 55, 66, and 77 share no common digit, so they can't be grouped together). Find the largest group size you can create.
Discussion
Loading comments…