From c25461b6b2883897e27ff2a0ff66a3faae7d3556 Mon Sep 17 00:00:00 2001 From: Piyush Ahire <113412805+piyush-ahire@users.noreply.github.com> Date: Wed, 28 Feb 2024 19:10:12 +0530 Subject: [PATCH] Update reverseString.cpp In line no. - 9, if(i >= j) ; return ; In the above snippet ( i>=j ) will be the correct condition because when only one character is there in string then it will not work. --- Lecture034 Recursion Day4/reverseString.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lecture034 Recursion Day4/reverseString.cpp b/Lecture034 Recursion Day4/reverseString.cpp index 18211037..b49ac810 100644 --- a/Lecture034 Recursion Day4/reverseString.cpp +++ b/Lecture034 Recursion Day4/reverseString.cpp @@ -6,7 +6,7 @@ void reverse(string& str, int i, int j ) { cout << "call recieved for " << str << endl; //base case - if(i>j) + if(i>=j) return ; swap(str[i], str[j]); @@ -27,4 +27,4 @@ int main() { cout << name << endl; return 0; -} \ No newline at end of file +}