首页 > 试题广场 >

元素查找

[编程题]元素查找
  • 热度指数:8833 时间限制:C/C++ 3秒,其他语言6秒 空间限制:C/C++ 32M,其他语言64M
  • 算法知识视频讲解

给定一个数组A及其大小n,同时给定需要查找的元素值x,已知数组A是由一个排过序的数组向左移位了一定长度得到的,请返回x在现数组的位置(位置从零开始)。保证数组中元素互异。

测试样例:
[6,1,2,3,4,5],6,6
返回:0
头像 诗云panther
发表于 2021-08-23 15:39:21
include include using namespace std; struct Tree{ int val; Tree *left, *right; Tree(int val):val(val), left(NULL), right(NULL){}}; Tree *Buil 展开全文
头像 Dfine
发表于 2025-07-08 18:58:46
#include <algorithm> #include <vector> class Finder { public: int findElement(vector<int> A, int n, int x) { // write 展开全文

问题信息

难度:
54条回答 17883浏览

热门推荐

通过挑战的用户

查看代码
元素查找