Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit607a679

Browse files
committed
Minor format change for JS problem 138
1 parent5dff205 commit607a679

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

‎javascript/138-Copy-List-with-Random-Pointer.js‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ var copyRandomList = function (head) {
1212
ptr=ptr.next;
1313
}
1414

15-
ptr=head;
16-
while(ptr){
17-
map.get(ptr).next=map.get(ptr.next)||null;
18-
map.get(ptr).random=map.get(ptr.random)||null;
19-
ptr=ptr.next;
15+
for(const[oldptr,newptr]ofmap){
16+
newptr.next=oldptr.next&&map.get(oldptr.next);
17+
newptr.random=oldptr.random&&map.get(oldptr.random);
2018
}
2119
returnmap.get(head);
2220
};

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp