Sort by

recency

|

2171 Discussions

|

  • + 0 comments

    Here is my c++ solution, you can watch video explanation here : https://youtu.be/Z_CYzW_sQAE

    Solution 1

    vector<int> reverseArray(vector<int> a) {
      reverse(a.begin(), a.end());
      return a;
    }
    

    Solution 2

    vector<int> reverseArray(vector<int> a) {
       vector<int> result; 
        for(int i = a.size() - 1; i >= 0; i--){
            result.push_back(a[i]);
        }
        return result;
    }
    
  • + 0 comments

    who can help me with the code using java

  • + 0 comments

    Extremelly easy (Perl):

    sub reverseArray {
        my $arr = shift;
        return reverse(@$arr);
    
    }
    
  • + 0 comments

    def reverse_array(): a = list(map(int, input("Enter numbers separated by spaces: ").split())) a_reversed = list(reversed(a)) return a_reversed

  • + 0 comments

    Java8

    public static List<Integer> reverseArray(List<Integer> a) {
    // Write your code here
        Collections.reverse(a);
        return a;
    }