Skip to main content

38 docs tagged with "Arrays"

View All Tags

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.

Add Binary

Given two binary strings a and b, return their sum as a binary string.

Asteroid Collision

We are given an array asteroids of integers representing asteroids in a row.

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.

Contiguous Array

Given a binary array nums, return the maximum length of a contiguous subarray with an equal number of 0 and 1.

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.

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.

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.

Group Anagrams

Given an array of strings strs, group the anagrams together. You can return the answer in any order.

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.

Longest Common Prefix

Write a function to find the longest common prefix string amongst an array of strings.

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.

Min Stack

Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.

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.

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.

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).

Palindrome Number

Given an integer x, return true if x is a palindrome, and false otherwise.

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].

Range Query Sum Immutable

Calculate the sum of the elements of nums between indices left and right inclusive where left <= right.

Ransome Note

Given two strings ransomNote and magazine, return true if ransomNote can be constructed by using the letters from magazine and false otherwise.

Rotate Array

Given an integer array nums, rotate the array to the right by k steps, where k is non-negative.

Rotate Image

You have to rotate the image in-place, which means you have to modify the input 2D matrix directly.

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.

Single Number

Given a non-empty array of integers nums, every element appears twice except for one. Find that single one.

Spiral Matrix

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

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).

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.

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.

Valid Anagram

Given two strings s and t, return true if t is an anagram of s, and false otherwise.

Valid Parentheses

Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.