From 671f5f67d57b24b1a5ba4bfc4455da7c75aadfcc Mon Sep 17 00:00:00 2001 From: dolphinflow86 Date: Mon, 3 Aug 2026 21:37:58 +0900 Subject: [PATCH 1/3] reverse linked list solution --- reverse-linked-list/dolphinflow86.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 reverse-linked-list/dolphinflow86.py diff --git a/reverse-linked-list/dolphinflow86.py b/reverse-linked-list/dolphinflow86.py new file mode 100644 index 0000000000..905079f98a --- /dev/null +++ b/reverse-linked-list/dolphinflow86.py @@ -0,0 +1,16 @@ +# TC: O(N) - visits each node exactly once +# SC: O(1) - reverses the links in place +class Solution: + + def reverseList(self, head: Optional[ListNode]) -> Optional[ListNode]: + prev = None + current = head + + while current: + next_node = current.next + current.next = prev + prev = current + current = next_node + + return prev + From 925fad36661eb38ed62dd24eb0f59cc03c1cd8f4 Mon Sep 17 00:00:00 2001 From: dolphinflow86 Date: Tue, 4 Aug 2026 23:06:04 +0900 Subject: [PATCH 2/3] longest substring without repeating characters solution --- .../dolphinflow86.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 longest-substring-without-repeating-characters/dolphinflow86.py diff --git a/longest-substring-without-repeating-characters/dolphinflow86.py b/longest-substring-without-repeating-characters/dolphinflow86.py new file mode 100644 index 0000000000..7d0f78f68f --- /dev/null +++ b/longest-substring-without-repeating-characters/dolphinflow86.py @@ -0,0 +1,20 @@ +# N is the length of s. +# TC: O(N) - each character is added and removed at most once +# SC: O(N) - stores the characters in the current window +class Solution: + + def lengthOfLongestSubstring(self, s: str) -> int: + chars = set() + left = 0 + longest = 0 + + for right, char in enumerate(s): + while char in chars: + chars.remove(s[left]) + left += 1 + + chars.add(char) + longest = max(longest, right - left + 1) + + return longest + From fe7b603126cd8208bf5b25dbe8aba6485c4c9324 Mon Sep 17 00:00:00 2001 From: dolphinflow86 Date: Wed, 5 Aug 2026 22:19:58 +0900 Subject: [PATCH 3/3] number of islands solution --- number-of-islands/dolphinflow86.py | 36 ++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 number-of-islands/dolphinflow86.py diff --git a/number-of-islands/dolphinflow86.py b/number-of-islands/dolphinflow86.py new file mode 100644 index 0000000000..0a9760a273 --- /dev/null +++ b/number-of-islands/dolphinflow86.py @@ -0,0 +1,36 @@ +# R is the number of rows, and C is the number of columns. +# TC: O(R * C) - visits each cell at most once +# SC: O(R * C) - uses the recursion stack in the worst case +class Solution: + + def numIslands(self, grid: List[List[str]]) -> int: + rows = len(grid) + cols = len(grid[0]) + + def dfs(row, col): + if ( + row < 0 + or row >= rows + or col < 0 + or col >= cols + or grid[row][col] != "1" + ): + return + + grid[row][col] = "0" + + dfs(row - 1, col) + dfs(row + 1, col) + dfs(row, col - 1) + dfs(row, col + 1) + + islands = 0 + + for row in range(rows): + for col in range(cols): + if grid[row][col] == "1": + islands += 1 + dfs(row, col) + + return islands +