Can any1 help me pls? i got AC..i appplies linear search..is it correctt?


  • 0
    A

    class Solution {
    public:
    int search(vector<int>& nums, int target) {
    int i,j;
    j=nums.size();
    for(i=0;i<j;i++)
    {
    if(nums[i]==target)
    return i;
    }
    return -1;
    }
    };


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.