Data Structures & Algorithms
237 notes
Some notes are currently available only in Chinese. English translations are shown when available.
- Continuous Positive Sequences with Sum Shistorical
Given a positive integer S, find all sequences of at least two consecutive positive integers whose sum is S.
- Swap Nodes in Pairshistorical
Given a linked list, swap every two adjacent nodes and return the head of the modified list. You must solve the problem without modifying node values (only node links may be changed).
- Last Remaining Number in a Circlehistorical
Arrange n numbers in a circle and repeatedly remove every m-th number. Find the last remaining number.
- Reverse Linked List IIhistorical
Given a singly linked list and positions left and right, reverse the nodes in that range and return the updated list.
- Arrange an Array into the Smallest Numberhistorical
Given an array of positive integers, concatenate all numbers to form one number and print the smallest possible result. For example, for {3,32,321}, the smallest number that can be formed is 321323.
- Count Occurrences in a Sorted Arrayhistorical
Count how many times a number appears in a sorted array.
- Reverse Nodes in k-Grouphistorical
Reverse the nodes of the given linked list in groups of k and return the resulting list. If the number of nodes is not a multiple of k, leave the remaining nodes at the end unchanged.
- Number Appearing More Than Half the Timehistorical
An array contains a number that appears more than half the length of the array. Find this number. For example, in the length-9 array {1,2,3,2,2,2,5,4,2}, the number 2 appears five times, which is more than half the array length, so output 2.
- Add Two Numbershistorical
You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each node stores a single digit.