12/

directory
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 24, 2026 License: BSD-3-Clause

README

Name

singly - singly linked list

Problem

Reverse a singly linked list.

Example

Input: [1, 2, 3]

Output: [3, 2, 1]

Solution

Details

Algorithm:

  • keep track of the previous and current nodes initialized to nil and the start of the list.
  • while current node is not nil, cache the next node reference, link current node to the previous one, and set previous to current and current to the next.

Complexity:

  • Time: O(n)
  • Space: O(1)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL