From cacaf821d9a30065efae298d502321554beea862 Mon Sep 17 00:00:00 2001 From: Harsh A Dubey <107762558+1032210414@users.noreply.github.com> Date: Sun, 2 Jun 2024 12:03:44 +0530 Subject: [PATCH] Create 344-Reverse String.cpp Write a function that reverses a string. The input string is given as an array of characters s. You must do this by modifying the input array in-place with O(1) extra memory. Example 1: Input: s = ["h","e","l","l","o"] Output: ["o","l","l","e","h"] Example 2: Input: s = ["H","a","n","n","a","h"] Output: ["h","a","n","n","a","H"] Constraints: 1 <= s.length <= 105 s[i] is a printable ascii character. --- cpp/344-Reverse String.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 cpp/344-Reverse String.cpp diff --git a/cpp/344-Reverse String.cpp b/cpp/344-Reverse String.cpp new file mode 100644 index 000000000..826bcd418 --- /dev/null +++ b/cpp/344-Reverse String.cpp @@ -0,0 +1,11 @@ +class Solution { +public: + void reverseString(vector& s) { + int f=0; + int l=s.size()-1; + while(f