Quick actions

cmd+k|ctrl+k

Navigation

Languages

reverseString

Snippet info

Language

Cpp

Visibility

public

Author

preeti.gaur1790

Created

2022-05-31T05:35:27.654331Z

Updated

2022-05-31T05:36:12.8262Z

#include <iostream>
using namespace std;



void reverseString(string s) {
   
    int high = s.length() - 1;
    int low = 0;
    
    // string reversedString;
     
     //cout << reversedString;
     while (low < high) {
          cout << "low : " << low << endl ;
          cout << "high : " << high << endl;
         char temp = s[low];
         s[low] = s[high];
         s[high] = temp;
         low ++;
         high --;
     }
    
     
    // for (int i= len-1; i>=0; i--) {
    //     reversedString.push_back(s[i]);
    // }
    cout << s;
}

int main() {
   // cout << fibo(6) << endl;
   reverseString("abcde");
    return 0;
}
INFO