27. Reverse a String
My Approach
Time and Auxiliary Space Complexity
Code (C++)
class Solution
{
public:
string reverseWord(string str)
{
int i = 0, j = str.size() - 1;
while (i < j)
{
swap(str[i], str[j]);
++i;
--j;
}
return str;
}
};Contribution and Support
Last updated