📄️ Guidelines
The category is named Arrays but it actually contains hints on how to work with many container types. Below are few tips/cheatsheet to remember while tackling array problems:
📄️ Two Sum
Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.
📄️ Move Zeroes
Given an integer array nums, move all 0's to the end of it while maintaining the relative order of the non-zero elements.
📄️ Contains Duplicate
Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct.
📄️ Missing Number
Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array.
📄️ Find All Numbers Disappeared in an Array
Given an array nums of n integers where nums[i] is in the range [1,n], return an array of all the integers in the range [1,n] that do not appear in nums.
📄️ Convert 1D Array into 2D Array
You are given a 0-indexed 1-dimensional (1D) integer array original, and two integers, m and n. You are tasked with creating a 2-dimensional (2D) array with m rows and n columns using all the elements from original.
📄️ Longest Palindrome
Given a string s which consists of lowercase or uppercase letters, return the length of the longest palindrome that can be built with those letters.
📄️ Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings.
📄️ Single Number
Given a non-empty array of integers nums, every element appears twice except for one. Find that single one.
📄️ Palindrome Number
Given an integer x, return true if x is a palindrome, and false otherwise.
📄️ Valid Anagram
Given two strings s and t, return true if t is an anagram of s, and false otherwise.
📄️ Ransome Note
Given two strings ransomNote and magazine, return true if ransomNote can be constructed by using the letters from magazine and false otherwise.
📄️ Number of 1 Bits
Write a function that takes an unsigned integer and returns the number of '1' bits it has (also known as the Hamming weight).
📄️ Reverse Bits
Reverse bits of a given 32 bits unsigned integer.
📄️ Add Binary
Given two binary strings a and b, return their sum as a binary string.
📄️ Roman to Integer
Given a roman numeral, convert it to an integer.
📄️ Majority Element
Given an array nums of size n, return the majority element.
📄️ Range Query Sum Immutable
Calculate the sum of the elements of nums between indices left and right inclusive where left <= right.
📄️ Valid Parentheses
Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.
📄️ Implement Queue using Stacks
Implement a first in first out (FIFO) queue using only two stacks. The implemented queue should support all the functions of a normal queue...
📄️ Find All Duplicates In Array
Given an integer array nums of length n where all the integers of nums are in the range [1, n] and each integer appears once or twice, return an array of all the integers that appears twice.
📄️ Find the Duplicate Number
There is only one repeated number in nums, return this repeated number.
📄️ Min Stack
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.
📄️ String to Integer (atoi)
Implement the myAtoi(string s) function, which converts a string to a 32-bit signed integer (similar to C/C++'s atoi function).
📄️ Evaluate Reverse Polish Notation
You are given an array of strings tokens that represents an arithmetic expression in a Reverse Polish Notation.
📄️ Set Matrix Zeroes
Given an m x n integer matrix matrix, if an element is 0, set its entire row and column to 0's.
📄️ Rotate Array
Given an integer array nums, rotate the array to the right by k steps, where k is non-negative.
📄️ Spiral Matrix
Given an m x n matrix, return all elements of the matrix in spiral order.
📄️ Rotate Image
You have to rotate the image in-place, which means you have to modify the input 2D matrix directly.
📄️ Group Anagrams
Given an array of strings strs, group the anagrams together. You can return the answer in any order.
📄️ Product of Array Except Self
Given an integer array nums, return an array answer such that answer[i] is equal to the product of all the elements of nums except nums[i].
📄️ Valid Sudoku
Determine if a 9 x 9 Sudoku board is valid.
📄️ Subarray Sum Equals K
Given an array of integers nums and an integer k, return the total number of subarrays whose sum equals to k.
📄️ Contiguous Array
Given a binary array nums, return the maximum length of a contiguous subarray with an equal number of 0 and 1.
📄️ Longest Consecutive Sequence
Given an unsorted array of integers nums, return the length of the longest consecutive elements sequence.
📄️ Asteroid Collision
We are given an array asteroids of integers representing asteroids in a row.
📄️ Accounts Merge
Given a list of accounts where each element accounts[i] is a list of strings, where the first element accounts[i][0] is a name, and the rest of the elements are emails representing emails of the account.
📄️ Daily Temperatures
Given an array of integers temperatures represents the daily temperatures, return an array answer such that answer[i] is the number of days you have to wait after the ith day to get a warmer temperature.
📄️ Largest Rectangle in Histogram
Given an array of integers heights representing the histogram's bar height where the width of each bar is 1, return the area of the largest rectangle in the histogram.
📄️ First Missing Positive
Given an unsorted integer array nums, return the smallest missing positive integer.