Yahoo India Web Search

Search results

  1. Write a function that reverses a string by modifying the input array in-place with O(1) extra memory. See examples, constraints and discussion for this easy problem.

    • Submissions

      Can you solve this real interview question? Reverse String -...

  2. Can you solve this real interview question? Reverse String - Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

  3. Nov 8, 2016 · 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"]

  4. 344. Reverse String. Time: O (n) O(n) Space: O (1) O(1) C++ Java Python. 1 2 3 4 5 6 7 8 9 10. class Solution { public: void reverseString(vector<char>& s) { int l = 0; int r = s.size() - 1; while (l < r) swap(s[l++], s[r--]); } }; LeetCode Solutions in C++20, Java, Python, MySQL, and TypeScript.

  5. 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:

  6. 344. Reverse String. Easy. 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. class Solution: def reverseString(self, s: List[str]) -> None: s.reverse()

  7. May 4, 2024 · This problem requires us to perform a constant-space in-place reversal of a string. This is quite an easy problem to solve as we can simply use two pointers and a temp variable to do a character-by-character reversal of a string.