注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号
x
7/14/2023 Citadel OA 2题:求大米!!
1. Binary Game
HackerBit designed a game based on binary digits. You are required to find the answer to the following problem to win the game.
A binary string is a string consisting only of digits 0 and 1. A binary string is said to be good if:
The digit 1 only appears in groups of size one_ group, if it appears at all. For example, for one_ group= 2, "011 110110" satisfies this condition while "01101010" does not.
The digit 0 only appears in groups of size zero_ group, if it appears at all. For example, for zero_ group= 3, "11" satisfies this condition while "101010" does not.
For example, fo, 8)is 2.
Function Description
Complete the function minMoves in the editor below,
minMoves has the following parameters:
int n: the width and height of the square board
int startRow: the row of the starting location
int startCol: the column of the starting location
int endRow: the row of the target location
int endCol: the column of the target location
Returns:
int: a single integer that denotes the number of moves required or -1 if it is not possible to reach the target location. |