From 2034cd1763f5e5cb591e886cb89f4f21e5d3659b Mon Sep 17 00:00:00 2001 From: Musojon Date: Sat, 15 Jul 2023 17:17:27 +0500 Subject: [PATCH 1/2] adding soition for 30-day's problems --- solutions/059.md | 12 ++++++++++++ solutions/060.md | 13 +++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 solutions/059.md create mode 100644 solutions/060.md diff --git a/solutions/059.md b/solutions/059.md new file mode 100644 index 0000000..79b7cee --- /dev/null +++ b/solutions/059.md @@ -0,0 +1,12 @@ +### Typescript + +```typescript +function hasCycle(head: ListNode | null): boolean { + const check = new Set(); + while(head){ + if(check.has(head)) return true; + check.add(head); + head=head.next + } + return false +};``` \ No newline at end of file diff --git a/solutions/060.md b/solutions/060.md new file mode 100644 index 0000000..f835c28 --- /dev/null +++ b/solutions/060.md @@ -0,0 +1,13 @@ +### Typescript + +```Typescript +function detectCycle(head: ListNode | null): ListNode | null { + const check=new Set(); + while(head){ + if(check.has(head)) return head; + check.add(head); + head=head.next + } + return null +}; +``` \ No newline at end of file From 5daad0986b875db8d02a1a87112e4fbaf0a2db2d Mon Sep 17 00:00:00 2001 From: Musojon Date: Sat, 15 Jul 2023 17:21:20 +0500 Subject: [PATCH 2/2] adding label of poblems --- solutions/059.md | 1 + solutions/060.md | 1 + 2 files changed, 2 insertions(+) diff --git a/solutions/059.md b/solutions/059.md index 79b7cee..1290847 100644 --- a/solutions/059.md +++ b/solutions/059.md @@ -1,4 +1,5 @@ ### Typescript +141. Linked List Cycle ```typescript function hasCycle(head: ListNode | null): boolean { diff --git a/solutions/060.md b/solutions/060.md index f835c28..e09c6e7 100644 --- a/solutions/060.md +++ b/solutions/060.md @@ -1,4 +1,5 @@ ### Typescript +142. Linked List Cycle II ```Typescript function detectCycle(head: ListNode | null): ListNode | null {