deno.land / x / masx200_leetcode_test@10.6.5 / remove-duplicate-node-lcci / index.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { ListNode } from "../reverse-linked-list/ListNode.ts";
function removeDuplicateNodes(head: ListNode | null): ListNode | null { if (!head) return null; const occured = new Set<number>();
occured.add(head.val);
const result = new ListNode(head.val); let cur = result;
while (head) { if (!occured.has(head.val)) { occured.add(head.val);
cur.next = new ListNode(head.val); cur = cur.next; } head = head.next; } return result;}export default removeDuplicateNodes;
masx200_leetcode_test
leetcode题解和一些测试工具
DocumentationDocumentation
GitHub Repositorymasx200/leetcode-test
GitHub Stars
4

Version Info

Tagged at
4 months ago