DEV Community

Cover image for Complete reverseArray C++ Solution
He Codes IT
He Codes IT

Posted on

Complete reverseArray C++ Solution

I came through a question on LeetCode to complete a reverseArray function. We have an array and we have to return the array reversing all the elements inside it. For Example, we have an array “X” which has elements [1,2,3,4,5,6]. We have to write a function that will return the [6,5,4,3,2,1].

Question
Complete the reverseArray function. Parameters of reveseArray is a vector that we have to reverse. The return value must also be a vector. To read the Complete Question visit HERE
This question on LeetCode has Difficulty Level: Easy and Max Marks: 10
Note: In this problem a special type of array vectors are used, which are types of dynamic arrays. They have the ability to resize themselves while inserting and deleting elements.

Given Code

include

using namespace std;
string ltrim(const string &);
string rtrim(const string &);
vector split(const string &);
/*

  • Complete the 'reverseArray' function below. *
  • The function is expected to return an INTEGER_ARRAY.
  • The function accepts INTEGER_ARRAY a as parameter. */ vector reverseArray(vector a) { }

My Solution
To read about my Solution to this Problem Visit https://hecodesit.com/complete-reversearray-c-solution/

Top comments (0)