Intro to Tutorial Challenges

Sort by

recency

|

400 Discussions

|

  • + 0 comments

    Iterative solution with built-in functions

    int introTutorial(int V, vector<int> arr) {
        auto it = std::find(arr.begin(), arr.end(), V);
        if (it != arr.end()) return std::distance(arr.begin(), it);
        return -1;
    }
    
  • + 0 comments

    Here is problem solution in Python Java c++ c and Javascript - https://programmingoneonone.com/hackerrank-super-reduced-string-problem-solution.html

  • + 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));
    }
    
  • + 0 comments
    def introTutorial(V, arr):
        return arr.index(V)
    
  • + 0 comments
    function introTutorial(V, arr) {
        return arr.findIndex(element => element === V);
    }