-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
380dce8
commit 5a8d48f
Showing
4 changed files
with
36 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
__pycache__ | ||
.idea | ||
node_modules | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include <vector> | ||
using namespace std; | ||
|
||
class Solution { | ||
public: | ||
void reverseString(vector<char>& s) { | ||
int left = 0; | ||
int right = s.size() - 1; | ||
while (left < right) { | ||
char temp = s[left]; | ||
s[left] = s[right]; | ||
s[right] = temp; | ||
left++; | ||
right--; | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class Solution: | ||
def reverseString(self, s: List[str]) -> None: | ||
""" | ||
Do not return anything, modify s in-place instead. | ||
""" | ||
left = 0 | ||
right = len(s) - 1 | ||
|
||
while left < right: | ||
s[left], s[right] = s[right], s[left] | ||
left += 1 | ||
right -= 1 | ||
|
||
|