Skip to content

Commit

Permalink
iterative reverse string solution in dart
Browse files Browse the repository at this point in the history
  • Loading branch information
nkawaller committed Sep 17, 2023
1 parent 4077d1f commit df34ed3
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions dart/0344-reverse-string.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Time Complexity: O(n)
// Space Complexity: O(1)

class Solution {
void reverseString(List<String> s) {
var l = 0, r = s.length - 1;
while (l <= r) {
var tmp = s[l];
s[l] = s[r];
s[r] = tmp;
l += 1;
r -= 1;
}
}
}

0 comments on commit df34ed3

Please sign in to comment.