#217. 递归查找数组中的特定数字

    ID: 217 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatWarmup-2gesp5递归一维数组

递归查找数组中的特定数字

Find Number 6 Recursively

Background

Congcong is currently learning about recursive algorithms. He encountered an interesting problem that requires determining if a specific number is present in an integer array.

Problem Description

Given an array of integers, compute recursively if the array contains the number 66. We'll use the convention of considering only the part of the array that begins at the given index. In this way, a recursive call can pass index+1index+1 to move down the array. The initial call will pass in indexindex as 00.

Input Format

Input is given from standard input in the following format.

A single line containing several integers. The last integer represents the starting index indexindex, and all preceding integers form the array to be checked.

Output Format

Output is printed to standard output in the following format.

Output true if the array contains 66; otherwise, output false.

Sample

1 6 4 0
true
1 4 0
false
6 0
true

Sample Explanation

For the first sample 1 6 4 0: The array is [1, 6, 4] and the starting index is 00. Starting from index 00, the array element arr[0]arr[0] is 11, which is not 66. A recursive call checks the array part [6, 4] starting from index 11. arr[1]arr[1] is 66, so it returns true.

Constraints

Time limit for each test case is 11 second, and memory limit is 10241024 KiB.