Skip to content

Commit beb1d85

Browse files
authoredDec 1, 2024
Merge pull request #2009 from thuanle123/0344-reverse-string
create 0344-reverse-string-csharp
2 parents 131fc44 + d8ed917 commit beb1d85

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
 

‎csharp/0344-reverse-string.cs

+17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
// While Loop Solution
2+
class Solution
3+
{
4+
public void ReverseString(char[] s)
5+
{
6+
int leftPointer = 0;
7+
int rightPointer = s.Length - 1;
8+
while (leftPointer < rightPointer)
9+
{
10+
char temp = s[leftPointer];
11+
s[leftPointer++] = s[rightPointer];
12+
s[rightPointer--] = temp;
13+
}
14+
}
15+
}
16+
17+
// For Loop Solution
118
public class Solution
219
{
320
public void ReverseString(char[] s)

0 commit comments

Comments
 (0)
Please sign in to comment.