Intro to Tutorial Challenges

  • + 0 comments

    Here are my c++ solutions, you can watch the explanation here : https://youtu.be/teDaBhua0bc

    solution 1:

    int introTutorial(int V, vector<int> arr) {
        for(int i = 0; i < arr.size(); i++) if(arr[i] == V) return i;
        return 0;
    }
    

    solution 2:

    int introTutorial(int V, vector<int> arr) {
        return distance(arr.begin(), find(arr.begin(), arr.end(), V));
    }