给定一个不下降的序列Sn{s1, s2... sn},以及一个m,* * * * */
找到最小的k,使得s[k] = m,如果不存在输出-1 test case :S = {1,3,4} m = 3 , k = 2 S = {1,2,2,2,,2} m = 2, k = 2
public class Problem2 { public static void main(String[] args) { System.out.println(find(new int[]{1}, 2));//-1 System.out.println(find(new int[]{2,3}, 2));//1 System.out.println(find(new int[]{1,2}, 2));//2 System.out.println(find(new int[]{1,3,4}, 3)); //2 System.out.println(find(new int[]{1,2,2,2,2}, 2));//2 System.out.println(find(new int[]{2,2,2,2,2}, 2));//1 System.out.println(find(new int[]{1,1,3,3,4,5}, 2));//-1 } /**