LeetCode
leetcode.com › problems › reverse-string-ii
Reverse String II - LeetCode
Reverse String II - Given a string s and an integer k, reverse the first k characters for every 2k characters counting from the start of the string. If there are fewer than k characters left, reverse all of them.
LeetCode
leetcode.com › problems › reverse-words-in-a-string-ii
Reverse Words in a String II - LeetCode
Can you solve this real interview question? Reverse Words in a String II - 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.
Videos
09:12
344. Reverse String | 541. Reverse String II && LEETCODE EASY - ...
09:40
Reverse String II | Leetcode 541 | Amazon Google Facebook interview ...
04:27
Reverse String - Leetcode 344 - Java - YouTube
04:37
Reverse String - Leetcode 344 - 2 Pointers - (Python) - YouTube
09:03
Reverse String - 3 Ways - Leetcode 344 - Python - YouTube
AlgoMonster
algo.monster › liteproblems › 541
541. Reverse String II - In-Depth Explanation
In-depth solution and explanation for LeetCode 541. Reverse String II in Python, Java, C++ and more. Intuitions, example walk through, and complexity analysis. Better than official and forum solutions.
LeetCode
leetcode.com › problems › reverse-string
Reverse String - LeetCode
Reverse String - 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 [https://en.wikipedia.org/wiki/In-place_algorithm] with O(1) extra memory.
WalkCCC
walkccc.me › LeetCode › problems › 541
541. Reverse String II - LeetCode Solutions
LeetCode Solutions in C++23, Java, Python, MySQL, and TypeScript.
AlgoMonster
algo.monster › liteproblems › 186
186. Reverse Words in a String II - In-Depth Explanation
In-depth solution and explanation for LeetCode 186. Reverse Words in a String II in Python, Java, C++ and more. Intuitions, example walk through, and complexity analysis. Better than official and forum solutions.
YouTube
youtube.com › watch
Reverse String ii | LeetCode 541 | C++ - YouTube
LeetCode Solutions: https://www.youtube.com/playlist?list=PL1w8k37X_6L86f3PUUVFoGYXvZiZHde1SJune LeetCoding Challenge: https://www.youtube.com/playlist?list=...
Published June 4, 2020
LeetCode
leetcode.com › problems › reverse-words-in-a-string-iii
Reverse Words in a String III - LeetCode
Reverse Words in a String III - Given a string s, reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order. Example 1: Input: s = "Let's take LeetCode contest" Output: "s'teL ekat ...
YouTube
youtube.com › watch
LeetCode 541 | Reverse String II | Algorithm Explained (Java) - YouTube
The description reads:"Given a string and an integer k, you need to reverse the first k characters for every 2k characters counting from the start of the str...
Published August 15, 2020
GitHub
github.com › doocs › leetcode › blob › main › solution › 0100-0199 › 0186.Reverse Words in a String II › README_EN.md
leetcode/solution/0100-0199/0186.Reverse Words in a String II/README_EN.md at main · doocs/leetcode
*/ function reverseWords(s: string[]): void { const n = s.length; const reverse = (i: number, j: number): void => { for (; i < j; ++i, --j) { [s[i], s[j]] = [s[j], s[i]]; } }; for (let i = 0, j = 0; j <= n; ++j) { if (s[j] === ' ') { reverse(i, j - 1); i = j + 1; } else if (j === n - 1) { reverse(i, j); } } reverse(0, n - 1); }
Author doocs
GitHub
github.com › doocs › leetcode › blob › main › solution › 0500-0599 › 0541.Reverse String II › README_EN.md
leetcode/solution/0500-0599/0541.Reverse String II/README_EN.md at main · doocs/leetcode
class Solution: def reverseStr(self, s: str, k: int) -> str: cs = list(s) for i in range(0, len(cs), 2 * k): cs[i : i + k] = reversed(cs[i : i + k]) return "".join(cs) class Solution { public String reverseStr(String s, int k) { char[] cs = s.toCharArray(); int n = cs.length; for (int i = 0; i < n; i += k * 2) { for (int l = i, r = Math.min(i + k - 1, n - 1); l < r; ++l, --r) { char t = cs[l]; cs[l] = cs[r]; cs[r] = t; } } return new String(cs); } }
Author doocs
Spark Code Hub
sparkcodehub.com › leetcode › 541 › reverse-string-ii
LeetCode 541: Reverse String II Solution in Python – A Step-by-Step Guide
k = 2, you’d flip "ab" to "ba" and "cd" to "dc," leaving "efg" as is, resulting in "bacdfeg." That’s the fun challenge of LeetCode 541: Reverse String II, an easy-to-medium problem that’s a fantastic way to practice string manipulation in Python.
LeetCode
leetcode.com › problems › reverse-words-in-a-string
Reverse Words in a String - LeetCode
Can you solve this real interview question? Reverse Words in a String - Given an input string s, reverse the order of the words. A word is defined as a sequence of non-space characters.
LeetCode
leetcode.ca › all › 186.html
Leetcode 186. Reverse Words in a String II
Given an input string , reverse the string word by word.
WalkCCC
walkccc.me › LeetCode › problems › 186
186. Reverse Words in a String II - LeetCode Solutions
LeetCode Solutions in C++23, Java, Python, MySQL, and TypeScript.
AlgoMonster
algo.monster › liteproblems › 344
344. Reverse String - In-Depth Explanation
In-depth solution and explanation for LeetCode 344. Reverse String in Python, Java, C++ and more. Intuitions, example walk through, and complexity analysis. Better than official and forum solutions.