Professional Documents
Culture Documents
Input : a string (max length is 1000) Output : length of longest alternating sub string.
Sample Cases 1: Input: 00110101001 Output: 6\n Explanation : it has a sub string "101010" in it.
Sample Cases 2: Input: 000 Output: 1\n Explanation : it has sub string "0" in it.
Sample Cases 3: Input: 0000011111 Ouput: 2\n Explanation: it has substring "01" in it.
Input : First line contain N size of array(3 <= N <= 5000).next line contain N distinct integer separated by spaces. Output : Print the answer in a single line, followed by a new line ('\n'). Note : '\n' at the end of output in sample cases is just to make sure you print a new line after the answer, no need to display '\n' in output.
Sample Case 2: Input: 5 1 -1 2 4 3 Output: 5\n Explanation: 1 = -1+2, 2 = -1+3, 3=1+2, 3 =-1+4, 4=1+3
Input First line contains N K ( 2 <= K <= N <= 100,000 ). N lines follow, each has a position suitable for tap to be installed. You can imagine the road as a straight line ( x-axis ). ( 0 <= xi <= 109 ) Output Print the answer in a single line, followed by a new line ( just a '\n', no need to display ) Time Limit : 1s
Sample Case Input 53 1 2 8 4 9 Output 3\n Explanation We can install the 3 taps at x = 1, 4 and 8. The minimum gap is between 1 and 4 = 4 - 1 = 3. You can't select any other 3 places such that the minimum distance is more than 3.