给定一个数组A及其大小n,同时给定需要查找的元素值x,已知数组A是由一个排过序的数组向左移位了一定长度得到的,请返回x在现数组的位置(位置从零开始)。保证数组中元素互异。 测试样例: [6,1,2,3,4,5],6,6 返回:0
加载中...
import java.util.*; public class Finder { public int findElement(int[] A, int n, int x) { // write code here } }
class Finder { public: int findElement(vector
A, int n, int x) { // write code here } };
# -*- coding:utf-8 -*- class Finder: def findElement(self, A, n, x): # write code here
class Finder { public int findElement(int[] A, int n, int x) { // write code here } }