Complete InterviewCake reverse-string-in-place
Wrote a function in TypeScript to reverse an array of characters mutatively.
This commit is contained in:
parent
e1427dd8b1
commit
5ec5a6da8c
2 changed files with 13 additions and 6 deletions
|
@ -1,6 +1,13 @@
|
||||||
function main(x: number) {
|
// Reverse array of characters, `xs`, mutatively.
|
||||||
console.log(x + 1);
|
function reverse(xs: Array<string>) {
|
||||||
console.log("Hello, world.");
|
let i: number = 0;
|
||||||
}
|
let j: number = xs.length - 1;
|
||||||
|
|
||||||
main(10);
|
while (i < j) {
|
||||||
|
let tmp = xs[i];
|
||||||
|
xs[i] = xs[j]
|
||||||
|
xs[j] = tmp
|
||||||
|
i += 1
|
||||||
|
j -= 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
* Array and string manipulation
|
* Array and string manipulation
|
||||||
** TODO Merging Meeting Times
|
** TODO Merging Meeting Times
|
||||||
** TODO Reverse String in Place
|
** DONE Reverse String in Place
|
||||||
** TODO Reverse Words
|
** TODO Reverse Words
|
||||||
** TODO Merge Sorted Arrays
|
** TODO Merge Sorted Arrays
|
||||||
** TODO Cafe Order Checker
|
** TODO Cafe Order Checker
|
||||||
|
|
Loading…
Add table
Reference in a new issue