map
Data Structures & Algorithms · 7 notes
- First Missing Positivehistorical
Given an unsorted integer array nums, find the smallest positive integer that does not appear in the array.
- 3Sumhistorical
Given an array nums containing n integers, determine whether there are three elements a, b, and c such that a + b + c = 0. Find all unique triplets whose sum is 0.
- Find the Duplicate Numberhistorical
Given n + 1 integers whose values range from 1 to n, find the repeated number.
- Two Sumhistorical
Given an integer array, find two numbers in the array whose sum equals the target value. The twoSum function should return the indices of these two numbers (index1, index2), with index1 < index2.
- Find All Numbers Disappeared in an Arrayhistorical
An array of length n contains values from 1 to n, some once and some twice. Find the values in this range that do not appear in the array.
- Subarray Sum Equals Khistorical
Given an integer array and an integer k, find the number of contiguous subarrays whose sum equals k.
- Longest Consecutive Sequencehistorical
Given an unsorted integer array nums, find the length of the longest sequence of consecutive numbers. The elements do not need to be contiguous in the original array.