Skip to main content
509, Fibonacci Number

I Problem

The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1. That is,

  • F(0) = 0, F(1) = 1
  • F(n) = F(n - 1) + F(n - 2), for n > 1

MikeAbout 3 mindynamic programmingeasyrecursionmemoizationmathdynamic programming
24, Swap Nodes in Pairs

I Problem

Given a linked list, swap every two adjacent nodes and return its head. You must solve the problem without modifying the values in the list's nodes (i.e., only nodes themselves may be changed.)

Example 1

Input: head = [1, 2, 3, 4]
Output: [2, 1, 4, 3]


MikeAbout 1 minlinkedlistmediumlinked listrecursion
206, Reverse Linked List

I Problem

Given the head of a singly linked list, reverse the list, and return the reversed list.

Example 1

Input: head = [1, 2, 3, 4, 5]
Output: [5, 4, 3, 2, 1]

Example 2

Input: head = [1, 2]
Output: [2, 1]

Example 3
Input: head = []
Output: []


MikeAbout 1 minlinkedlisteasylinked listrecursion
203, Remove Linked List Elements

I Problem

Given the head of a linked list and an integer val, remove all the nodes of the linked list that has Node.val == val, and return the new head.

Example 1

Input: head = [1, 2, 6, 3, 4, 5, 6], val = 6
Output: [1, 2, 3, 4, 5]

Example 2
Input: head = [], val = 1
Output: []


MikeAbout 1 minlinkedlisteasylinked listrecursion