Skip to content

Commit

Permalink
chore: add brackets for conditional expression
Browse files Browse the repository at this point in the history
  • Loading branch information
sandrig committed Jul 25, 2023
1 parent dcb0e1a commit 84202b1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions typescript/src/insertDeleteGetRandom/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,19 @@ class RandomizedSet {
}

insert(val: number): boolean {
if (this.map.has(val)) return false;
if (this.map.has(val)) {
return false;
}

this.map.set(val, this.list.length);
this.list.push(val);
return true;
}

remove(val: number): boolean {
if (!this.map.has(val)) return false;
if (!this.map.has(val)) {
return false;
}

const index = this.map.get(val) as number;
const lastElement = this.list[this.list.length - 1];
Expand Down
9 changes: 7 additions & 2 deletions typescript/src/insertDeleteGetRandom/randomizedSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@ export class RandomizedSet {
}

insert(val: number): boolean {
if (this.map.has(val)) return false;
if (this.map.has(val)) {
return false;
}

this.map.set(val, this.list.length);
this.list.push(val);
return true;
}

remove(val: number): boolean {
if (!this.map.has(val)) return false;
if (!this.map.has(val)) {
return false;
}

const index = this.map.get(val) as number;
const lastElement = this.list[this.list.length - 1];
Expand Down

0 comments on commit 84202b1

Please sign in to comment.