Skip to main content

408 docs tagged with "Array"

View all tags

01 Matrix

This is a solution to the 542. 01 Matrix problem on LeetCode.

3Sum losest (LeetCode)

Given an integer array nums of length n and an integer target, find three integers in nums such that the sum is closest to target.

Ant on the Boundary (LeetCode)

Determine how many times an ant returns to the boundary after reading an array of non-zero integers and moving according to their values.

Arithmetic Number

This tutorial covers the solution to the Find the Arithmetic Number problem from the GeeksforGeeks.

Array Leaders

This tutorial covers the solution to the Array Leaders problem from the GeeksforGeeks website.

Array Nesting

This is a solution to the Array Nesting problem on LeetCode.

Balanced Array

This document covers methods to check if an array is balanced in various programming languages.

Battleships in a Board

Given an `m x n` board where each cell is a battleship 'X' or empty '.', count the number of battleships on the board.

Best Time to Buy and Sell Stock

This article provides a solution to the Best Time to Buy and Sell Stock problem, which finds the maximum profit that can be obtained by buying and selling a stock at most once.

Binary Array Sorting

This document provides solutions for sorting a binary array, where elements are either 0 or 1.

Binary Search

This document provides solutions to the problem of performing Binary Search in a sorted array.

Binary Search

This is a solution to the Binary Search problem on LeetCode.

Burst-Ballons

This is a solution to the Burst Ballons problem on LeetCode.

Car Fleet

Return the number of distinct groups of cars (car fleets) that reach the target mile together, where a fleet is formed when a faster car catches up to a slower car and they travel at the slower car's speed.

Chalkboard XOR Game

Alice and Bob take turns erasing one number from the chalkboard. If removing a number makes the bitwise XOR of all remaining numbers become 0, the player who made that move loses. If at any player's turn, the XOR of all numbers on the chalkboard is already 0, that player wins. Alice starts first, and both play optimally to avoid losing.

Check Equal Arrays

This document provides solutions to whether two arrays are equal or not.

Closest Number

This document covers methods to find the closest number to a given target in an array in various programming languages.

Coin Change

This is a solution to the Coin Change problem on LeetCode.

Coin Change 2

You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money. Return the number of combinations that make up that amount.

Combination Sum-II(LeetCode)

Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where the candidate numbers sum to target.

Combination Sum(LeetCode)

Given an array of distinct integers candidates and a target integer target, return a list of all unique combinations of candidates where the chosen numbers sum to target.

Common in 3 Sorted Arrays

This tutorial covers the solution to the Common in 3 Sorted Arrays problem from the GeeksforGeeks website, featuring implementations in Python and C++.

Container With Most Water (LeetCode)

Given n non-negative integers representing the heights of vertical lines, find the two lines that together with the x-axis form a container, such that the container contains the most water.

Contains Duplicate II(LeetCode)

Given an integer array nums and an integer k, return true if there are two distinct indices i and j in the array such that nums[i] == nums[j] and abs(i - j) <= k.

Contains Duplicate(LeetCode)

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.

Corporate Flight Bookings

Solve the problem of calculating the total number of seats reserved for each flight using the booking intervals and prefix sum technique.

Count Pairs with Given Sum

This tutorial covers the solution to the Count Pairs with Given Sum problem from the GeeksforGeeks website, featuring implementations in Python and C++.

Count Primes

This is a solution to the Count Primes problem on LeetCode.

Elements in the Range

This document covers methods to find elements within a specified range in an array in various programming languages.

Equilibrium Point

This tutorial covers the solution to the Equilibrium Point problem from the GeeksforGeeks website, featuring implementations in Python and C++.

Exceptionally Odd

This document covers methods to find the element that occurs an odd number of times in an array in various programming languages.

Expressive Words

Given a string s and an array of query strings words, return the number of words that can be transformed into s by extending groups of identical characters in the word to have a size of three or more.

Fair Candy Swap

Find one pair of candy boxes, one from Alice and one from Bob, to swap so they both end up with the same total number of candies.

Faithful Numbers

This tutorial covers the solution to the Faithful Numbers problem from the GeeksforGeeks website.

Faulty Keyboard

This is a solution to the Faulty Keyboard problem on LeetCode.

Find and Replace Pattern

Given a list of strings words and a string pattern, return words that match pattern where each unique character in pattern maps uniquely to characters in the word.

Find Duplicates in an Array (gfg)

This tutorial covers the solution to the Find Duplicates in an Array problem from the GeeksforGeeks website, featuring implementations in Python and C++.

Find Pair Given Difference

This tutorial covers the solution to the Find Pair Given Difference problem from the GeeksforGeeks website, featuring implementations in C++.

Find Peak Element

A peak element is an element that is strictly greater than its neighbors. Given a 0-indexed integer array nums, find a peak element, and return its index. If the array contains multiple peaks, return the index to any of the peaks. You may imagine that nums[-1] = nums[n] = -∞. In other words, an element is always considered to be strictly greater than a neighbor that is outside the array. You must write an algorithm that runs in O(log n) time.

Find the Duplicate Number

Given an array of N + 1 size, where each element is between 1 and N. Assuming there is only one duplicate number, your task is to find the duplicate number.

Find the Grid of Region Average

Calculate the m x n grid result, where result[i][j] is the average intensity of the regions to which image[i][j] belongs, rounded down to the nearest integer.

Find Triplet with Zero Sum

This document explores different approaches to solving the problem of finding a triplet in an array that sums up to zero, including solutions in JavaScript, TypeScript, Python, Java, and C++.

First and Last Occurrences of X

This document covers methods to find the first and last occurrences of a specified element X in an array in various programming languages.

First Repeating Element

This tutorial covers the solution to the First Repeating Element problem from the GeeksforGeeks website, featuring implementations in C++.

Floor in a Sorted Array Problem (gfg)

This tutorial covers the solution to the Floor in a Sorted Array problem from the GeeksforGeeks website, featuring implementations in Python and C++.

Friends Of Appropriate Ages

Calculate the total number of friend requests made between persons based on their ages, following specific conditions that determine when a friend request is not sent.

GCD of Array

This document covers methods to calculate the Greatest Common Divisor (GCD) of an array of integers in various programming languages.

Greater on Right Side

This document covers methods to replace every element with the greatest element in various programming languages.

Grid Game

This is a solution to the Grid Game problem where two robots play optimally on a 2D grid.

H-Index (LeetCode)

Given an array of integers citations where citations[i] is the number of citations a researcher received for their ith paper, return the researcher's h-index.

Harshad-Number

This is a solution to the Harshad Number problem on LeetCode.

Heaters

This is a solution to the heaters problem on LeetCode.

Height Checker

Given an array heights, return the number of indices where heights[i] != expected[i].

House Robber IV

This is a solution to the House Robber IV problem on LeetCode.

Insert Interval(LeetCode)

You are given an array of non-overlapping intervals intervals. Insert newInterval into intervals such that intervals is still sorted in ascending order by starti and intervals still does not have any overlapping intervals. Return intervals after the insertion.

Ishaan Loves Chocolates

This document covers methods for determining the tastiness level of the square which his sister gets in various programming languages.

Jump Game

You are given an integer array nums. You are initially positioned at the array's first index, and each element in the array represents your maximum jump length at that position.

Jump Game II(LeetCode)

You are given a 0-indexed array of integers nums of length `n`. Return the minimum number of jumps to reach `nums[n - 1]`.

K-Similar Strings

Determine the minimum number of adjacent letter swaps needed to transform string s1 into string s2, given that s1 and s2 are anagrams.

Largest Number(LeetCode)

Given a list of non-negative integers nums, arrange them such that they form the largest number and return it.

Last Index of One

This document covers methods to find the last index of '1' various programming languages.

Lonely Pixel I

Given an m x n picture consisting of black 'B' and white 'W' pixels, return the number of black lonely pixels.

Loud and Rich

Return an integer array answer where answer[x] = y indicates that y is the person with the least quietness among all individuals who have equal to or more money than person x.

Majority Element

Given an array nums of size n, return the majority element. The majority element is the element that appears more than ⌊n / 2βŒ‹ times. You may assume that the majority element always exists in the array.

Max Consecutive Ones

Given a binary array nums, return the maximum number of consecutive 1's in the array.

Maximal Square

This document provides a solution where we find the largest square containing only 1's and return its area.

Maximum Days Without Darkness

This document covers methods to find the maximum number of days the room remains illuminated using candles that reduce by 1 unit each day, given an array representing the sizes of the candles.

Maximum Gap(LeetCode)

Given an integer array nums, return the maximum difference between two successive elements in its sorted form. If the array contains less than two elements, return 0.

Merge Intervals(LeetCode)

Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that cover all the intervals in the input.

Min Stack

Given the sorted rotated array nums of unique elements, return the minimum element of this array.

Minimum Cost to Cut a Stick

Solve the problem of finding the minimum cost to cut a stick into smaller pieces at specified positions, using dynamic programming.

Minimum Elements to Add to Form a Given Sum

Solve the problem of finding the minimum number of elements to add to an array to make the sum equal to a given goal while maintaining the property that absolute value of elements does not exceed a specified limit.

Minimum Path Sum(LeetCode)

Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right, which minimizes the sum of all numbers along its path.

Missing Number

This document covers methods to find the missing number in an array in various programming languages.

Monotonic Array

The problem no. is 1351. The Problem is to find monotonic array.

Move Zeroes

This is a solution to the move zeroes in leetcode

Move Zeroes(LeetCode)

Given an integer array nums, move all 0's to the end of it while maintaining the relative order of the non-zero elements.

Multiple-Strings(LeetCode)

Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string.

Multiply Left and Right Array Sum

This document covers methods to calculate the product of the left and right array sums for a given array in various programming languages.

Next Greater Element II

Given a circular integer array nums (i.e., the next element of `nums[nums.length - 1]` is `nums[0]`), return the next greater number for every element in nums..

Number of Lines To Write String

Write the string ss across multiple lines with each line no wider than 100 pixels, counting the total number of lines and the width of the last line, given the widths of each letter.

Pancake Sorting

This is a solution to the Pancake Sorting problem on LeetCode.

Patching Array

This document provides solutions for the Patching Array problem.

Peak Element

This document provides solutions to the problem of finding peak element in an array.

Peak Index in a Mountain Array

Find the index of the peak element in a mountain array (an array that increases to a peak and then decreases) in O(log(n)) time complexity.

Permutation-2

Given a collection of numbers, nums, that might contain duplicates, return all possible unique permutations in any order.

Permutations(LeetCode)

Given an array `nums` of distinct integers, return all the possible permutations. You can return the answer in any order.

Pour Water.

This is a solution to Pour Water problem on LeetCode.

Preorder Traversal

This document provides solutions to preorder traversal of a binary tree.

Product of Array Elements

This document covers methods to calculate the product of all elements in an array in various programming languages.

Relative Ranks

This document provides solutions for the Relative Ranks problem.

Reverse a String

This document provides solutions to the problem of reversing a string.

Rotate Array

This is a solution to the Rotate Array problem on LeetCode.

Rotating an Array

This document provides solutions for rotating an array to the left or right by a specified number of positions.

Searching a number

This document provides solutions to finding the position of an element in the array.

Second Largest Element

This tutorial covers the solution to the Second Largest Distinct Element problem from the GeeksforGeeks.

Shortest Distance to a Character

Given a string ss and a character cc that appears in ss, return an array where each element at index ii represents the minimum distance from ii to any occurrence of cc in ss.

Single Element in a Sorted Array

You are given a sorted array consisting of only integers where every element appears exactly twice, except for one element which appears exactly once. Return the single element that appears only once.

Single Number III

Given an integer array `nums`, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once. You can return the answer in any order.

Smallest Rectangle Enclosing Black Pixels

Given an image represented by a binary matrix where 0 is a white pixel and 1 is a black pixel, return the area of the smallest rectangle that encloses all black pixels. The black pixels are connected, and the rectangle must be axis-aligned.

Sort Colors

This is a solution to the Two Sum problem on LeetCode.

Spiral Matrix

This document provides a solution to the Spiral Matrix problem, where the goal is to traverse a matrix in spiral order.

Split Array With Same Average

This document provides a solution where we split an array into two non-empty subsets such that both subsets have the same average.

Stone Game III

This is a solution to the Stone Game III problem on LeetCode.

Subdomain Visit Count

Given an array of count-paired domains, return an array showing the total visit counts for each subdomain and its parent domains.

Teemo Attacking

This is a solution to the Teemo Attacking problem on LeetCode.

Trapping Rain Water(LeetCode)

Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining.

Two Out of Three

Return a distinct array containing all the values that are present in at least two out of the three arrays.

Type of Triangle (LeetCode)

Determine the type of triangle that can be formed by an array of integers representing the sides of the triangle.

Union Of Two Arrays

This document provides solutions to the problem of finding the number of elements in the union between two arrays.

Unique Paths II(LeetCode)

There is a robot initially located at the top-left corner. The robot tries to move to the bottom-right corner. Return the number of possible unique paths that the robot can take to reach the bottom-right corner.

Wave Array

This tutorial covers the solution to the Wave Array problem from the GeeksforGeeks website, featuring implementations in C++.

Wiggle Sort II

This is a solution to the Wiggle Sort II problem on LeetCode.

Word Break(LeetCode)

Given a string s and a dictionary of strings wordDict, return true if s can be segmented into a space-separated sequence of one or more dictionary words.

Word Search II

This document provides a solution to the Word Search II problem, where we need to return all words on the board, given an mXn board of characters and a list of strings words.

Word Search(LeetCode)

Given an m x n grid of characters board and a string word, return true if word exists in the grid.

Word Subsets

This is a solution to the Word Subsets problem on LeetCode.