Practice · 19 problems
Arrays & Hashing
0 of 19 solved on this device
- 001Two SumGiven an array of integers `nums` and an integer `target`, return the indices of the two numbers such that they add up to `target`. Exactly one valid answer exists, and you may not use the same element twice.Easy
- 002Contains DuplicateGiven an integer array `nums`, return `true` if any value appears at least twice, and `false` if every element is distinct.Easy
- 003Product of Array Except SelfGiven an integer array `nums`, return an array `answer` where `answer[i]` is the product of all elements of `nums` except `nums[i]`. You must solve it WITHOUT using division, in O(n) time.Medium
- 004Maximum SubarrayGiven an integer array `nums`, find the contiguous subarray with the largest sum and return that sum. The subarray must contain at least one element.Medium
- 005Group AnagramsGiven an array of strings `strs`, group the anagrams together. Return the groups in any order; the strings inside a group may be in any order.Medium
- 006Top K Frequent ElementsGiven an integer array `nums` and an integer `k`, return the `k` most frequent elements. The answer may be returned in any order.Medium
- 051Valid AnagramGiven two strings `s` and `t`, return true if `t` is an anagram of `s`. An anagram uses exactly the same characters with the same counts, reordered.Easy
- 052Longest Consecutive SequenceGiven an unsorted array `nums`, return the length of the longest sequence of consecutive integers in it. The elements need not be adjacent in the array. Must run in O(n) time.Medium
- 053Subarray Sum Equals KGiven an integer array `nums` and an integer `k`, return the total number of contiguous subarrays whose sum equals `k`.Medium
- 101Majority ElementGiven an array `nums` of size n, return the element that appears more than n/2 times. You may assume a majority element always exists.Easy
- 102Move ZeroesGiven an array `nums`, move all zeroes to the end while keeping the relative order of the non-zero elements. You must do this IN PLACE without copying the array.Easy
- 103Rotate ArrayGiven an array `nums`, rotate it to the right by `k` steps, where k is non-negative. Solve it in place with O(1) extra space.Medium
- 164Contains Duplicate IIGiven an integer array `nums` and an integer `k`, return true if there are two DISTINCT indices i and j such that nums[i] == nums[j] and |i - j| <= k.Easy
- 165Isomorphic StringsTwo strings `s` and `t` are isomorphic if the characters in `s` can be replaced to get `t`. Every occurrence of a character must be replaced with the same character, preserving order. No two characters may map to the same character, but a character may map to itself. Return true if `s` and `t` are isomorphic.Easy
- 166Find All Numbers Disappeared in an ArrayGiven an array `nums` of n integers where each nums[i] is in the range [1, n], return an array of all the integers in [1, n] that do not appear in `nums`. Any order is accepted.Easy
- 167Majority Element IIGiven an integer array `nums` of size n, return all elements that appear MORE than n/3 times. Any order is accepted.Medium
- 168Find All Duplicates in an ArrayGiven an integer array `nums` of length n where every value is in [1, n] and each value appears ONCE or TWICE, return an array of all the values that appear twice. Any order is accepted.Medium
- 169First Missing PositiveGiven an unsorted integer array `nums`, return the smallest positive integer that is NOT present in `nums`. You must run in O(n) time and use O(1) auxiliary space.Hard
- 170Longest PalindromeGiven a string `s` of lowercase and uppercase letters, return the length of the longest palindrome that can be BUILT from those letters (each letter used at most as many times as it appears). Letters are case sensitive: "Aa" is not a palindrome.Easy