Problems

Build your DSA foundation one pattern at a time.

#7
Find Minimum in Rotated Sorted Array
Medium
Modified Binary Search
Binary Search

Practice this problem and implement an efficient solution.

Array
Binary Search
#9
3Sum
Medium
Sort + Two Pointers
Two Pointers

Practice this problem and implement an efficient solution.

Array
Two Pointers
#11
Longest Substring Without Repeating Characters
Medium
Variable Sliding Window
Sliding Window

Practice this problem and implement an efficient solution.

String
Hash Map
#12
Longest Repeating Character Replacement
Medium
Frequency Window
Sliding Window

Practice this problem and implement an efficient solution.

String
Sliding Window
#13
Minimum Window Substring
Hard
Variable Sliding Window
Sliding Window

Practice this problem and implement an efficient solution.

String
Hash Map
#16
Valid Palindrome
Easy
Two Pointers
Two Pointers

Practice this problem and implement an efficient solution.

String
Two Pointers
#17
Valid Parentheses
Easy
Monotonic Matching
Stack

Given a string s containing only the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: 1. Open brackets are closed by the same type of bracket. 2. Open brackets are closed in the correct order. 3. Every closing bracket has a corresponding open bracket.

String
Stack
#18
Min Stack
Medium
Auxiliary Stack
Stack

Practice this problem and implement an efficient solution.

Stack
Design
#19
Daily Temperatures
Medium
Monotonic Stack
Stack

Practice this problem and implement an efficient solution.

Array
Monotonic Stack
#20
Evaluate Reverse Polish Notation
Medium
Stack Simulation
Stack

Practice this problem and implement an efficient solution.

Stack
Math
#21
Reverse Linked List
Easy
Pointer Manipulation
Linked List

Practice this problem and implement an efficient solution.

Linked List
Recursion
#22
Merge Two Sorted Lists
Easy
Two Pointers
Linked List

Practice this problem and implement an efficient solution.

Linked List
Recursion
#23
Linked List Cycle
Easy
Fast and Slow Pointers
Linked List

Practice this problem and implement an efficient solution.

Linked List
Two Pointers
#24
Remove Nth Node From End of List
Medium
Fast and Slow Pointers
Linked List

Practice this problem and implement an efficient solution.

Linked List
Two Pointers
#25
LRU Cache
Medium
Hash Map + Doubly Linked List
Linked List

Practice this problem and implement an efficient solution.

Design
Hash Table
Linked List
#26
Binary Tree Inorder Traversal
Easy
DFS
Trees

Practice this problem and implement an efficient solution.

Tree
Stack
#27
Maximum Depth of Binary Tree
Easy
DFS
Trees

Practice this problem and implement an efficient solution.

Tree
Recursion
#28
Invert Binary Tree
Easy
Tree Recursion
Trees

Practice this problem and implement an efficient solution.

Tree
DFS
#29
Binary Tree Level Order Traversal
Medium
BFS
Trees

Practice this problem and implement an efficient solution.

Tree
Queue
#30
Validate Binary Search Tree
Medium
DFS Bounds
BST

Practice this problem and implement an efficient solution.

Tree
BST
DFS
#31
Kth Smallest Element in a BST
Medium
Inorder Traversal
BST

Practice this problem and implement an efficient solution.

Tree
BST
#32
Lowest Common Ancestor of a Binary Tree
Medium
Postorder DFS
Trees

Practice this problem and implement an efficient solution.

Tree
DFS
#33
Binary Tree Maximum Path Sum
Hard
Tree DP
Trees

Practice this problem and implement an efficient solution.

Tree
DFS
DP
#34
Kth Largest Element in an Array
Medium
Top K
Heap

Practice this problem and implement an efficient solution.

Array
Heap
#36
Find Median from Data Stream
Hard
Two Heaps
Heap

Practice this problem and implement an efficient solution.

Heap
Design
#37
Number of Islands
Medium
Grid DFS / BFS
Graphs

Practice this problem and implement an efficient solution.

Graph
Grid
DFS
#38
Clone Graph
Medium
Graph Traversal
Graphs

Practice this problem and implement an efficient solution.

Graph
DFS
BFS
#39
Course Schedule
Medium
Topological Sort
Graphs

Practice this problem and implement an efficient solution.

Graph
BFS
DFS
#40
Pacific Atlantic Water Flow
Medium
Reverse DFS
Graphs

Practice this problem and implement an efficient solution.

Graph
Grid
DFS
#41
Word Ladder
Hard
BFS
Graphs

Practice this problem and implement an efficient solution.

Graph
String
BFS
#42
Word Search
Medium
Grid Backtracking
Backtracking

Practice this problem and implement an efficient solution.

Grid
DFS
Backtracking
#43
Subsets
Medium
Decision Tree
Backtracking

Practice this problem and implement an efficient solution.

Array
Backtracking
#44
Permutations
Medium
Decision Tree
Backtracking

Practice this problem and implement an efficient solution.

Array
Backtracking
#45
Combination Sum
Medium
Decision Tree
Backtracking

Practice this problem and implement an efficient solution.

Array
Backtracking
#46
N-Queens
Hard
Constraint Backtracking
Backtracking

Practice this problem and implement an efficient solution.

Backtracking
Matrix
#47
Climbing Stairs
Easy
1D DP
Dynamic Programming

Practice this problem and implement an efficient solution.

DP
Memoization
#48
House Robber
Medium
1D DP
Dynamic Programming

Practice this problem and implement an efficient solution.

DP
Array
#49
Coin Change
Medium
Unbounded Knapsack
Dynamic Programming

Practice this problem and implement an efficient solution.

DP
Array
#50
Longest Increasing Subsequence
Medium
DP + Binary Search
Dynamic Programming

Practice this problem and implement an efficient solution.

DP
Binary Search
#51
Word Break
Medium
String DP
Dynamic Programming

Practice this problem and implement an efficient solution.

DP
String
#52
Unique Paths
Medium
Grid DP
Dynamic Programming

Practice this problem and implement an efficient solution.

DP
Matrix
#53
Partition Equal Subset Sum
Medium
0/1 Knapsack
Dynamic Programming

Practice this problem and implement an efficient solution.

DP
Knapsack
#54
Single Number
Easy
XOR
Bit Manipulation

Practice this problem and implement an efficient solution.

Bit Manipulation
Array
#55
Number of 1 Bits
Easy
Bit Counting
Bit Manipulation

Practice this problem and implement an efficient solution.

Bit Manipulation
#56
Counting Bits
Easy
DP + Bits
Bit Manipulation

Practice this problem and implement an efficient solution.

DP
Bit Manipulation
#59
Merge Intervals
Medium
Interval Merge
Arrays

Practice this problem and implement an efficient solution.

Array
Sorting
#60
Insert Interval
Medium
Interval Merge
Arrays

Practice this problem and implement an efficient solution.

Array
Intervals
#61
Non-overlapping Intervals
Medium
Interval Greedy
Greedy

Practice this problem and implement an efficient solution.

Greedy
Sorting
#62
Meeting Rooms II
Medium
Heap + Intervals
Heap

Practice this problem and implement an efficient solution.

Heap
Intervals
#64
Two Sum II
Medium
Two Pointers
Two Pointers

TODO: Add the complete problem description.

Array
Two Pointers
Binary Search
#65
Squares of a Sorted Array
Easy
Two Pointers
Two Pointers

TODO: Add the complete problem description.

Array
Two Pointers
Sorting
#101
Binary Search
Easy
Binary Search
Binary Search

TODO: Add the complete problem description.

Array
Binary Search
#102
Search Insert Position
Easy
Lower Bound
Binary Search

TODO: Add the complete problem description.

Array
Binary Search
#103
Search in Rotated Sorted Array
Medium
Modified Binary Search
Binary Search

You are given an integer array nums sorted in ascending order with distinct values. Before being passed to your function, nums may have been rotated at an unknown pivot. Given nums and target, return the index of target if it exists. Otherwise, return -1. Your solution should run in O(log n) time.

Array
Binary Search
#104
Find Peak Element
Medium
Binary Search on Answer
Binary Search

A peak element is an element that is strictly greater than its neighbors. Given a 0-indexed integer array nums, return the index of any peak element. You may imagine nums[-1] = nums[n] = -infinity.

Array
Binary Search
#201
Two Sum
Easy
Hash Map Lookup
Array

Given an array of integers nums and an integer target, return the indices of the two numbers such that they add up to target. You may assume that each input has exactly one solution, and you may not use the same element twice. You can return the answer in any order.

Array
Hash Table
#202
Contains Duplicate
Easy
Frequency Set
Array

Given an integer array nums, return true if any value appears at least twice in the array. Return false if every element is distinct.

Array
Hash Table
Sorting
#203
Best Time to Buy and Sell Stock
Easy
Running Minimum
Array

You are given an array prices where prices[i] represents the price of a stock on the ith day. You want to maximize your profit by choosing one day to buy one stock and choosing a later day to sell that stock. Return the maximum profit you can achieve. If no profit can be achieved, return 0.

Array
Dynamic Programming
#204
Maximum Subarray
Medium
Kadane's Algorithm
Array

Given an integer array nums, find the contiguous subarray with the largest sum and return its sum. The subarray must contain at least one element.

Array
Dynamic Programming
Divide and Conquer
#205
Product of Array Except Self
Medium
Prefix and Suffix Products
Array

Given an integer array nums, return an array answer where answer[i] equals the product of every element of nums except nums[i]. Solve it without using division.

Array
Prefix Sum
#206
Majority Element
Easy
Boyer-Moore Voting
Array

Given an array nums of size n, return the majority element. The majority element appears more than floor(n / 2) times and is guaranteed to exist.

Array
Hash Table
Divide and Conquer
Counting
#207
Move Zeroes
Easy
In-Place Compaction
Array

Given an integer array nums, move all zeroes to the end while maintaining the relative order of all non-zero elements. Return the transformed array.

Array
Two Pointers
#208
Rotate Array
Medium
Array Reversal
Array

Given an integer array nums and a non-negative integer k, rotate the array to the right by k positions and return the resulting array.

Array
Math
Two Pointers
#209
Missing Number
Easy
Index Range Invariant
Array

Given an array nums containing n distinct numbers taken from the range [0, n], return the only number from that range that is missing.

Array
Hash Table
Math
Bit Manipulation
#210
Maximum Product Subarray
Medium
Dual Running Extremes
Array

Given an integer array nums, find the contiguous non-empty subarray that has the largest product and return that product.

Array
Dynamic Programming
#211
Find Pivot Index
Easy
Prefix Sum Balance
Array

Given an integer array nums, return the leftmost pivot index where the sum of elements strictly to the left equals the sum of elements strictly to the right. Return -1 if no pivot exists.

Array
Prefix Sum
#212
Sort Colors
Medium
Dutch National Flag
Array

Given an array nums containing only 0, 1 and 2, sort the values in-place so equal values are adjacent and ordered 0, 1, 2. Return the sorted array.

Array
Two Pointers
Sorting
#213
Next Permutation
Medium
Lexicographical Rearrangement
Array

Given an integer array nums representing a permutation, rearrange it into the lexicographically next greater permutation. If no greater permutation exists, rearrange it into the smallest possible order. Return the resulting array.

Array
Two Pointers
#214
Merge Sorted Array
Easy
Reverse Two Pointers
Array

Given two sorted integer arrays nums1 and nums2, return a single sorted array containing all elements from both arrays.

Array
Two Pointers
Sorting
#215
Remove Duplicates from Sorted Array
Easy
Slow and Fast Pointers
Array

Given a sorted integer array nums, return an array containing each distinct value exactly once while preserving sorted order.

Array
Two Pointers
#216
First Missing Positive
Hard
Cyclic Placement
Array

Given an unsorted integer array nums, return the smallest positive integer that does not appear in nums.

Array
Hash Table
#217
Find All Numbers Disappeared in an Array
Easy
Index Marking
Array

Given an integer array nums of length n where every value is between 1 and n, return all numbers in the range [1, n] that do not appear in nums.

Array
Hash Table
#218
Find All Duplicates in an Array
Medium
Index Sign Marking
Array

Given an integer array nums of length n where each value is between 1 and n and each value appears once or twice, return all values that appear twice.

Array
Hash Table
#219
Set Matrix Zeroes
Medium
Matrix Marker Compression
Array

Given an m x n integer matrix, if an element is 0, set its entire row and column to 0. Return the resulting matrix.

Array
Matrix
Hash Table
#220
Spiral Matrix
Medium
Boundary Simulation
Array

Given an m x n matrix, return all elements of the matrix in spiral order.

Array
Matrix
Simulation
#221
Rotate Image
Medium
Transpose and Reverse
Array

Given an n x n matrix, rotate the matrix 90 degrees clockwise and return the rotated matrix.

Array
Matrix
Math
#222
Jump Game
Medium
Greedy Reachability
Array

You are given an integer array nums where nums[i] represents the maximum jump length from index i. Return true if you can reach the final index starting from index 0.

Array
Greedy
Dynamic Programming
#223
Gas Station
Medium
Greedy Reset
Array

There are n gas stations arranged in a circle. gas[i] is the fuel available at station i and cost[i] is the fuel required to travel from station i to station i + 1. Return the starting station index from which the complete circuit can be traveled clockwise, or -1 if impossible.

Array
Greedy
#224
Candy
Hard
Two-Pass Greedy
Array

There are n children standing in a line, each with a rating. Every child must receive at least one candy, and children with a higher rating than an adjacent child must receive more candies than that child. Return the minimum total number of candies required.

Array
Greedy
#225
Container With Most Water
Medium
Two Pointers
Array

Given an integer array height where height[i] represents the height of a vertical line at position i, choose two lines that together with the x-axis form a container. Return the maximum amount of water the container can hold.

Array
Two Pointers
Greedy
#226
Trapping Rain Water
Hard
Two Pointers
Array

Given n non-negative integers representing an elevation map where the width of each bar is 1, return how much rain water can be trapped after raining.

Array
Two Pointers
Dynamic Programming
Stack
#227
Maximum Sum Circular Subarray
Medium
Circular Kadane
Array

Given a circular integer array nums, return the maximum possible sum of a non-empty subarray. A circular subarray may wrap from the end of the array back to the beginning, but each array element may be used at most once.

Array
Dynamic Programming
Kadane
#228
Subarray Sum Equals K
Medium
Prefix Sum Frequency
Array

Given an integer array nums and an integer k, return the total number of contiguous non-empty subarrays whose sum equals k.

Array
Hash Table
Prefix Sum
#229
Remove Element
Easy
In-place Compaction
Array

Given an integer array nums and an integer val, remove every occurrence of val conceptually in-place and return the remaining values while preserving their original relative order.

Array
Two Pointers
#230
Find the Duplicate Number
Medium
Floyd Cycle Detection
Array

Given an array nums containing n + 1 integers where every integer is in the range 1 to n inclusive, return the single repeated number. The repeated value may occur more than twice.

Array
Two Pointers
Binary Search
#231
Increasing Triplet Subsequence
Medium
Greedy Thresholds
Array

Given an integer array nums, return true if there exist indices i < j < k such that nums[i] < nums[j] < nums[k]. Otherwise return false.

Array
Greedy
#232
H-Index
Medium
Counting Buckets
Array

Given an array citations where citations[i] is the number of citations received by a researcher's ith paper, return the researcher's h-index. The h-index is the maximum h such that at least h papers each have at least h citations.

Array
Sorting
Counting Sort
#233
Pascal's Triangle
Easy
Row Simulation
Array

Given an integer numRows, return the first numRows of Pascal's triangle. Each interior value is the sum of the two values directly above it.

Array
Dynamic Programming
#234
Pascal's Triangle II
Easy
One-Dimensional DP
Array

Given a zero-based rowIndex, return the rowIndex-th row of Pascal's triangle.

Array
Dynamic Programming
#235
Game of Life
Medium
In-place State Encoding
Array

Given an m x n binary board representing cells in Conway's Game of Life, compute and return the board after one simultaneous update. A live cell survives with two or three live neighbors, while a dead cell becomes live with exactly three live neighbors.

Array
Matrix
Simulation
#236
Maximum Distance in Arrays
Medium
Running Extrema
Array

You are given multiple integer arrays, each sorted in non-decreasing order. Choose one integer from one array and another integer from a different array. Return the maximum possible absolute difference between the two chosen integers.

Array
Greedy
#301
Valid Anagram
Easy
Frequency Map
Hashing

Given two strings s and t, return true if t is an anagram of s. An anagram is formed by rearranging the letters of another word using all original characters exactly once.

Hash Table
String
Sorting
#302
Group Anagrams
Medium
Canonical Hash Key
Hashing

Given an array of strings strs, group the anagrams together. Strings belong to the same group when they contain exactly the same characters with the same frequencies. The groups and the strings inside each group may be returned in any order.

Array
Hash Table
String
Sorting
#303
Top K Frequent Elements
Medium
Frequency Map and Buckets
Hashing

Given an integer array nums and an integer k, return the k most frequent distinct elements. The answer may be returned in any order.

Array
Hash Table
Heap
Bucket Sort
#304
Valid Sudoku
Medium
Constraint Sets
Hashing

Given a partially filled 9 by 9 Sudoku board, determine whether the current board is valid. Each row, each column and each 3 by 3 sub-box must contain each digit from 1 through 9 at most once. Empty cells are represented by a period.

Array
Hash Table
Matrix
#305
Isomorphic Strings
Easy
Bidirectional Mapping
Hashing

Given two strings s and t, determine whether they are isomorphic. Every occurrence of a character in s must map to the same character in t, and two different characters in s cannot map to the same character in t.

Hash Table
String
#306
Word Pattern
Easy
Bidirectional Mapping
Hashing

Given a pattern and a space-separated string s, determine whether s follows the same pattern. Each pattern character must map to exactly one word and each word must map to exactly one pattern character.

Hash Table
String
#307
Happy Number
Easy
Cycle Detection Set
Hashing

Starting with a positive integer n, repeatedly replace the number by the sum of the squares of its digits. Return true if the process eventually reaches 1. Return false if it enters a cycle that never reaches 1.

Hash Table
Math
Two Pointers
#308
Intersection of Two Arrays
Easy
Set Intersection
Hashing

Given two integer arrays nums1 and nums2, return an array containing their distinct common elements. Each value must appear only once in the result, and the result may be returned in any order.

Array
Hash Table
Two Pointers
Binary Search
#309
Intersection of Two Arrays II
Easy
Frequency Intersection
Hashing

Given two integer arrays nums1 and nums2, return their intersection while preserving multiplicity. Each element in the result must appear as many times as it occurs in both arrays. The result may be returned in any order.

Array
Hash Table
Two Pointers
Sorting
#310
Ransom Note
Easy
Frequency Consumption
Hashing

Given two strings ransomNote and magazine, return true if ransomNote can be constructed using characters from magazine. Each character in magazine may be used at most once.

Hash Table
String
Counting
#311
First Unique Character in a String
Easy
Frequency Map
Hashing

Given a string s, find the first character that appears exactly once and return its index. Return -1 if no unique character exists.

Hash Table
String
Queue
Counting
#312
Longest Palindrome
Easy
Frequency Parity
Hashing

Given a string s containing lowercase and uppercase English letters, return the length of the longest palindrome that can be built using those characters. Character matching is case-sensitive.

Hash Table
String
Greedy
#313
Sort Characters By Frequency
Medium
Frequency Map and Buckets
Hashing

Given a string s, sort its characters in decreasing order based on their frequency and return the resulting string. Characters with the same frequency may appear in any relative order, but identical characters must remain grouped together.

Hash Table
String
Sorting
Heap
#314
Find Common Characters
Easy
Frequency Intersection
Hashing

Given an array of strings words, return all characters that appear in every string, including duplicates. The result may be returned in any order.

Array
Hash Table
String
#315
Unique Number of Occurrences
Easy
Frequency Uniqueness
Hashing

Given an array of integers arr, return true if the number of occurrences of every distinct value is unique. Otherwise return false.

Array
Hash Table
#316
Determine if Two Strings Are Close
Medium
Frequency Signature
Hashing

Two strings are considered close if one can be transformed into the other using any number of swaps between existing characters and swaps of the identities of two existing characters. Return true if word1 and word2 are close.

Hash Table
String
Sorting
#317
Equal Row and Column Pairs
Medium
Sequence Hashing
Hashing

Given an n by n integer matrix grid, return the number of pairs consisting of a row and a column that contain exactly the same values in exactly the same order.

Array
Hash Table
Matrix
#318
Brick Wall
Medium
Prefix Position Frequency
Hashing

A rectangular wall consists of rows of bricks. Every row has the same total width, but brick widths may differ. Draw one vertical line from top to bottom so that it crosses the fewest bricks. The line may pass through brick boundaries but cannot be drawn along either outer edge. Return the minimum number of crossed bricks.

Array
Hash Table
Prefix Sum
#319
Longest Harmonious Subsequence
Easy
Adjacent Frequency Pair
Hashing

A harmonious subsequence is a subsequence in which the difference between its maximum and minimum values is exactly 1. Given an integer array nums, return the length of its longest harmonious subsequence.

Array
Hash Table
Sorting
#320
Bulls and Cows
Medium
Frequency Reconciliation
Hashing

You are given two equal-length digit strings secret and guess. A bull is a digit that matches in both value and position. A cow is a non-bull digit from guess that exists elsewhere in secret. Return the hint in the form xAyB, where x is the number of bulls and y is the number of cows.

Hash Table
String
Counting
#321
Find Duplicate File in System
Medium
Content Grouping
Hashing

You are given directory descriptions. Each description contains a directory path followed by one or more files represented as fileName(content). Return groups of complete file paths whose files have identical content. Only groups containing at least two files should be returned. Groups and paths within groups may be returned in any order.

Array
Hash Table
String
#322
Minimum Index Sum of Two Lists
Easy
Indexed Lookup
Hashing

Given two arrays of unique strings list1 and list2, find all common strings whose index sum is the smallest among all common strings. Return the answer in any order.

Array
Hash Table
String
#323
Keyboard Row
Easy
Membership Sets
Hashing

Given an array of English words, return the words that can be typed using letters from only one row of a standard American keyboard. Letter matching is case-insensitive. The result may be returned in any order.

Array
Hash Table
String
#324
Uncommon Words from Two Sentences
Easy
Combined Frequency Map
Hashing

A word is uncommon if it appears exactly once in one sentence and does not appear in the other sentence. Given two space-separated sentences s1 and s2, return all uncommon words in any order.

Hash Table
String
Counting
#325
Longest Consecutive Sequence
Medium
Sequence Start Detection
Hashing

Given an unsorted array of integers nums, return the length of the longest sequence of consecutive integer values. The values do not need to appear consecutively in the original array.

Array
Hash Table
Union Find
#326
Subdomain Visit Count
Medium
Hierarchical Frequency Aggregation
Hashing

A count-paired domain contains a visit count followed by a domain. A visit to a domain also counts as a visit to every parent subdomain. Given an array cpdomains, return the accumulated visit count for every visited domain and subdomain. The result may be returned in any order.

Array
Hash Table
String
Counting
#327
Find the Difference
Easy
Frequency Difference
Hashing

You are given two strings s and t. String t is created by randomly shuffling string s and then adding one extra character. Return the character that was added.

Hash Table
String
Bit Manipulation
Sorting
#328
Check if the Sentence Is Pangram
Easy
Distinct Character Coverage
Hashing

A pangram is a sentence in which every lowercase English letter appears at least once. Given a string sentence containing lowercase English letters, return true if sentence is a pangram and false otherwise.

Hash Table
String
#329
Jewels and Stones
Easy
Membership Counting
Hashing

You are given strings jewels and stones. Every character in stones represents a stone you have, while every character in jewels represents a type of stone considered a jewel. Letters are case-sensitive. Return how many stones are jewels.

Hash Table
String
#330
Contains Duplicate II
Easy
Last Seen Index
Hashing

Given an integer array nums and an integer k, return true if there are two distinct indices i and j such that nums[i] equals nums[j] and the absolute difference between i and j is at most k.

Array
Hash Table
Sliding Window
#331
Degree of an Array
Easy
Frequency and Boundary Tracking
Hashing

The degree of an array is the maximum frequency of any of its elements. Given a non-empty integer array nums, return the smallest possible length of a contiguous subarray that has the same degree as nums.

Array
Hash Table
#332
Number of Good Pairs
Easy
Frequency Pair Counting
Hashing

Given an array of integers nums, return the number of good pairs. A pair of indices (i, j) is good when nums[i] equals nums[j] and i is less than j.

Array
Hash Table
Math
Counting
#333
K-diff Pairs in an Array
Medium
Unique Difference Pair Counting
Hashing

Given an integer array nums and a non-negative integer k, return the number of unique pairs of values whose absolute difference is exactly k. Pairs with the same two values count only once.

Array
Hash Table
Two Pointers
Sorting
#334
Find Original Array From Doubled Array
Medium
Frequency Reconstruction
Hashing

An original array was transformed by appending twice every element and then shuffling the result. Given the resulting non-negative integer array changed, reconstruct and return one valid original array. If no original array exists, return an empty array. The returned original values may appear in any order.

Array
Hash Table
Greedy
Sorting
#335
Array of Doubled Pairs
Medium
Absolute-Value Frequency Matching
Hashing

Given an integer array arr of even length, return true if it can be reordered so that for every pair of adjacent conceptual elements, one value is exactly twice the other. Equivalently, every value must be matched with its double.

Array
Hash Table
Greedy
Sorting
#336
Pairs of Songs With Total Durations Divisible by 60
Medium
Complement Remainder Counting
Hashing

You are given an array time where time[i] is the duration of a song in seconds. Return the number of index pairs (i, j), with i less than j, for which time[i] + time[j] is divisible by 60.

Array
Hash Table
Math
Counting