解题思路
直接暴力搜索吧
代码
#include<algorithm>
class Solution {
public:int search(int A[], int n, int target) {int res = -1;for(int i = 0;i < n;i++){if(A[i] == target){res = i;break;}}return res;}
};
直接暴力搜索吧
#include<algorithm>
class Solution {
public:int search(int A[], int n, int target) {int res = -1;for(int i = 0;i < n;i++){if(A[i] == target){res = i;break;}}return res;}
};