Open in app

Sign In

Write

Sign In

Steven Lu
Steven Lu

46 Followers

Home

About

Jan 11

LeetCode — Set Matrix Zeroes

Given an m x n integer matrix matrix, if an element is 0, set its entire row and column to 0's. You must do it in place. Example 1: Input: matrix = [[1,1,1],[1,0,1],[1,1,1]] Output: [[1,0,1],[0,0,0],[1,0,1]] Example 2:

Leetcode

1 min read

LeetCode — Set Matrix Zeroes
LeetCode — Set Matrix Zeroes
Leetcode

1 min read


Jan 9

LeetCode — Reorder List (Blind Curated 45)

You are given the head of a singly linked-list. The list can be represented as: L0 → L1 → … → Ln - 1 → Ln Reorder the list to be on the following form: L0 → Ln → L1 → Ln - 1 → L2 → Ln - 2 → … You may not modify the values in the list’s nodes. Only nodes themselves may be changed. Example 1: Input: head = [1,2,3,4] Output: [1,4,2,3] Example 2:

Leetcode

1 min read

LeetCode — Reorder List (Blind Curated 45)
LeetCode — Reorder List (Blind Curated 45)
Leetcode

1 min read


Jan 7

LeetCode — Remove Nth Node From End of List

Given the head of a linked list, remove the nth node from the end of the list and return its head. Example 1: Input: head = [1,2,3,4,5], n = 2 Output: [1,2,3,5] Example 2: Input: head = [1], n = 1 Output: [] Example 3: Input: head = [1,2], n = 1 Output: [1] Constraints: The number of nodes in the list is sz. 1 <= sz <= 30 0 <= Node.val <= 100 1 <= n <= sz Solution: Time complexity: O(N) Space complexity: O(N)

Leetcode

1 min read

LeetCode — Remove Nth Node From End of List
LeetCode — Remove Nth Node From End of List
Leetcode

1 min read


Dec 23, 2022

LeetCode — Merge K sorted lists (Blind Curated 43)

You are given an array of k linked-lists lists, each linked-list is sorted in ascending order. Merge all the linked-lists into one sorted linked-list and return it. Example 1: Input: lists = [[1,4,5],[1,3,4],[2,6]] Output: [1,1,2,3,4,4,5,6] Explanation: The linked-lists are: [ 1->4->5, 1->3->4, 2->6 ] merging them into one sorted list: 1->1->2->3->4->4->5->6 Example 2: Input: lists = [] Output: []

Leetcode Solution

1 min read

Leetcode Solution

1 min read


Dec 19, 2022

LeetCode — Non-overlapping intervals (Blind Curated 37)

Given an array of intervals intervals where intervals[i] = [starti, endi], return the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping. Example 1: Input: intervals = [[1,2],[2,3],[3,4],[1,3]] Output: 1 Explanation: [1,3] can be removed and the rest of the intervals are non-overlapping. Example 2: Input: intervals = [[1,2],[1,2],[1,2]] Output: 2 Explanation: You need to remove two [1,2] to make the rest of the intervals non-overlapping.

Leetcode Medium

1 min read

Leetcode Medium

1 min read


Dec 11, 2022

LeetCode — Insert Interval (Blind Curated 35)

You are given an array of non-overlapping intervals intervals where intervals[i] = [starti, endi] represent the start and the end of the ith interval and intervals is sorted in ascending order by starti. …

Leetcode Medium

1 min read

Leetcode Medium

1 min read


Dec 10, 2022

LeetCode — Longest consecutive sequence (Blind Curated 31)

Given an unsorted array of integers nums, return the length of the longest consecutive elements sequence. You must write an algorithm that runs in O(n) time. Example 1: Input: nums = [100,4,200,1,3,2] Output: 4 Explanation: The longest consecutive elements sequence is [1, 2, 3, 4]. Therefore its length is 4. Example 2: Input: nums = [0,3,7,2,5,8,4,6,0,1] Output: 9 Constraints: 0 <= nums.length <= 105

Leetcode Medium

1 min read

Leetcode Medium

1 min read


Dec 8, 2022

LeetCode — Number of Islands (Blind Curated 30)

Given an m x n 2D binary grid grid which represents a map of '1's (land) and '0's (water), return the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water. Example 1: Input: grid = [ ["1","1","1","1","0"], ["1","1","0","1","0"], ["1","1","0","0","0"], ["0","0","0","0","0"] ] Output: 1

Leetcode

1 min read

Leetcode

1 min read


Dec 7, 2022

LeetCode — Pacific Atlantic Water Flow (Blind Curated 29)

There is an m x n rectangular island that borders both the Pacific Ocean and Atlantic Ocean. The Pacific Ocean touches the island's left and top edges, and the Atlantic Ocean touches the island's right and bottom edges. The island is partitioned into a grid of square cells. You are…

Leetcode

2 min read

LeetCode — Pacific Atlantic Water Flow (Blind Curated 29)
LeetCode — Pacific Atlantic Water Flow (Blind Curated 29)
Leetcode

2 min read


Dec 6, 2022

LeetCode — Course Schedule (Blind Curated 28)

There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. You are given an array prerequisites where prerequisites[i] = [ai, bi] indicates that you must take course bi first if you want to take course ai. For example, the pair [0, 1]…

Leetcode

1 min read

Leetcode

1 min read

Steven Lu

Steven Lu

46 Followers

👨‍💻

Following
  • Cheng-Wei Hu | 胡程維

    Cheng-Wei Hu | 胡程維

  • 莫力全 Kyle Mo

    莫力全 Kyle Mo

  • John Wu

    John Wu

  • Byron Hsu

    Byron Hsu

  • 張育晟 Eason Chang

    張育晟 Eason Chang

See all (11)

Help

Status

Writers

Blog

Careers

Privacy

Terms

About

Text to speech