Remove Duplicate Numbers
Given a list of integers nums, remove numbers that appear multiple times in the list, while maintaining order of the appearance in the original list.
Given a list of integers nums, remove numbers that appear multiple times in the list, while maintaining order of the appearance in the original list.
Given an integer k and a list of integers nums, return the length of the longest sublist that contains at most k distinct integers.
You are given lists of integers people, jobs, profits. Each person i in people have people[i] amount of strength, and performing job j requires jobs[j] amoun...
Given a list of integers nums and an integer target, return the number of triples i < j < k that exist such that nums[i] + nums[j] + nums[k] < target.
You are given a list of integers nums and integer k. Return the maximum sum of elements that you can remove given that you must pop exactly k times, where ea...
You are given a list of integers nums containing 1s and 0s and an integer k. Given that you can set at most k 0s to 1s, return the length of the longest subl...
Given an unsorted array of integers nums, find the length of the longest sequence of consecutive elements.
You are given a list of integers nums. Return the length of the longest sublist such that its length is at least 3 and its values are strictly increasing and...
Given a list of strings lst and a list of integers p, reorder lst so that every lst[i] gets placed to p[i].
Given a list of distinct positive integers nums, find the largest subset such that every pair of elements in the subset (i, j) satisfies either i % j = 0 or ...
Given a two-dimensional integer matrix, sort each of the diagonals descending from left to right in ascending order.
You are given a two-dimensional list of strings matrix. Each element in matrix contains one of the following:
You are given a list of integers nums and a two-dimensional list of integers ranges. Each element in ranges contains [i, j], meaning to sum the numbers in nu...
Given a list of integers nums, we want to split the list into two non-empty sublists a and b such that every element in a is less than or equal to every elem...
You are given a list of non-negative integers nums. Return the maximum sum of a sublist in nums containing only unique values.
Given an integer n, return the next bigger permutation of its digits.
Implement a data structure with the following methods:
You are given a list of integers nums and an integer target. In one operation we can remove any two numbers in nums if the pair sums to target. Return the ma...
You are given a list of integers piles and an integer k. piles[i] represents the number of bananas on pile i. On each hour, you can choose any pile and eat r...
You are given a list of integers nums where each number represents a vote to a candidate.
You are given a list of integers nums and a two-dimensional list of integers queries. Each element in queries contains [i, j] and asks what is the value of n...
Given a list of integers nums and an integer k, return a list of count of distinct numbers in each window of size k.
A sequence is called bitonic if it’s strictly increasing and then strictly decreasing. A sequence that is only strictly increasing is bitonic. Also, a sequen...
Given a two-dimensional integer matrix, where every row and column is sorted in ascending order, find the kth (0-indexed) smallest number.
Given a two-dimensional integer matrix, where every row and column is sorted in ascending order, return whether an integer target exists in the matrix.
You are given a list of integers positions representing the position of a car at equally spaced intervals of time. Return the length of the longest sublist w...
Given a 2-d array matrix, return elements in spiral order starting from matrix[0][0].
You are given a two-dimensional list of integers matrix where each row is sorted in ascending order. Return the smallest number that exists in every row. If ...
You are given a two-dimensional list of integers matrix. Return the minimum sum you can get by taking a number in each row with the constraint that any row-a...
You are given a list of unique integers nums that is sorted in ascending order and is rotated at some pivot point. Find the maximum number in the rotated list.
Given a list of integers nums sorted in ascending order, remove in-place duplicates that appear more than twice.
Given a list of integers nums and an integer k, choose elements from nums to create a list of length k such that the difference between the largest integer i...
Given a two-dimensional square matrix, rotate in-place it 90 degrees counter-clockwise.
Given a list of integers nums, pack consecutive elements of the same value into sublists.
Given a list of sorted lists of integers, merge them into one large sorted list.
You are given a two-dimensional list of integers matrix which contains 1s and 0s. Given that each row is sorted in ascending order with 0s coming before 1s, ...
The n queens puzzle asks to place n queens on an n×n chessboard so that no two queens are attacking each other.
You are given a list of non-negative integers piles where each piles[i] represents the number of coins on pile i. In each move, you can do the following unti...
Given two lists of integers lst0 and lst1, each of length n and where each value is unique to its array and between 0 to n - 1, return the minimum number of ...
Given a list of integers prices representing the stock prices of a company in chronological order, return the maximum profit you could have made from buying ...
Given a list of integers prices representing the stock prices of a company in chronological order, return the maximum profit you could have made from buying ...
Given a two-dimensional matrix of characters board and a string target, return whether the target can be found in the matrix by going left-to-right, or up-to...
Given an integer square (n by n) matrix, return its transpose. A transpose of a matrix switches the row and column indices. That is, for every r and c, matri...
Given a two-dimensional matrix of integers matrix, determine whether it’s a Toeplitz matrix. A Toeplitz is one where every diagonal descending from left to r...
You are given a list of integers tasks and another list of integers people. The integer tasks[i] represents the amount of strength required to perform the it...
Given a list of integers nums, swap each consecutive even indexes with each other, and swap each consecutive odd indexes with each other.
Given a list of numbers nums and a number k, return whether any two elements from the list add up to k. You may not use the same element twice.
Given a list of integers nums sorted in ascending order and an integer k, return whether any two elements from the list add up to k. You may not use the same...
Given a list of integers nums and an integer target, return the sum of the largest pair of numbers in nums whose sum is less than target. You can assume that...
Given a list of integers nums and an integer k, determine if there are three distinct elements in the list that add up to k.
Given a list of integers nums, return whether the list is strictly increasing or strictly decreasing.
Given a list of integers sorted in ascending order nums, square the elements and give the output in sorted order.
You are given a list of integers nums. Let k be the frequency of a most frequent number in nums. Return the length of a shortest sublist such that the freque...
Given a list of integers nums, return the length of the shortest sublist in nums which if sorted would make nums sorted in ascending order.
Given a list of strings sentence where each sentence[i] is a string with single character, reverse the order of the words in the sentence.
Write a function that rotates a list of numbers to the left by k elements. Numbers should wrap around.
Given a list of integers nums, find all duplicate numbers and delete their last occurrences.
You are given a list of integers nums and a two-dimensional list of integers operations. Each operation is of the following form: [L, R, X], which means that...
Implement a data structure with the following methods:
You are given a list of non-negative integers nums where each element represents the height of a hill. Suppose it will rain and all the spaces between two si...
You are given a list of integers nums sorted in ascending order, and integers a, b, and c. Apply the following function for each number x in nums: \(ax^2 + b...
Given a list of positive integers nums, return the number of integers that have odd number of digits.
Given a list of integers nums and an integer target, return the number of sublists whose sum is equal to target.
Given a list of integers nums, sort the array such that:
You are given a list of integers nums. Return the minimum positive value we can append to the beginning of nums such that prefix sums of the resulting list c...
Given a list of integers nums, return the minimum cost of sorting the list in ascending or descending order. The cost is defined as the sum of absolute diffe...
You are given a list of integers nums and an integer k. Given that you must first remove a sublist of length k, return the minimum resulting max(nums) - min(...
Given two lists of integers a and b sorted in ascending order, merge them into one large sorted list.
Given a list of integers nums, split it into two lists of equal size where the absolute difference between each list’s median is as small as possible and ret...
Given an integer n, return the maximum number you can make by inserting 5 anywhere in the number.
You are given a list of integers seats containing 1s and 0s. Each element seats[i] represents a seat and is either occupied if seats[i] = 1 or empty if seats...
Given a list of integers nums, find the largest product of three distinct elements.
Given a two-dimensional integer matrix, return a new matrix A of the same dimensions where each element is set to A[i][j] = sum(matrix[r][c]) for all r ≤ i, ...
Given a list of non-zero integers nums, return the length of longest subsequence that flips signs on each consecutive number.
Given a list of lowercase alphabet strings words, return the length of the longest contiguous sublist where all words share the same first letter.
Given a list of strings strs, containing the strings "red", "green" and "blue", partition the list so that the red come before green, which come before blue.
Given a list of integers nums, replace every nums[i] with the smallest integer left of i. Replace nums[0] with 0.
You are given three positive integers n, lower, and upper. You want to create a list of length n that is strictly increasing and then strictly decreasing and...
You are given a list of integers nums, representing the number of chess matches each person has won. Return a relative ranking (0-indexed) of each person. If...
You are given a list of integers nums and an integer k. Consider an operation where you pick an element in nums and negate it. Given that you must make exact...
Given a list of unsorted integers nums, and an integer k, return the kth (0-indexed) smallest element in the list.
Given a list of integers nums and an integer k, return the maximum possible i where nums[0] + nums[1] + ... + nums[i] ≤ k. Return -1 if no valid i exists.
You are given a list of non-negative integers nums. If there are exactly k numbers in nums that are greater than or equal to k, return k. Otherwise, return -1.
Given a list of integers nums, sorted in ascending order, and a number target, return the index where target should be inserted to keep nums sorted. If targe...
Given a list of integer nums, return the earliest index i such that the sum of the numbers left of i is equal to the sum of numbers right of i. If there’s no...
Given a list of integers nums, put all the zeros to the back of the list by modifying the list in-place. The relative ordering of other elements should stay ...
Given an integer list nums where each number represents the maximum number of hops you can make, determine whether you can reach to the last index starting a...
Given a list of unique integers nums sorted in ascending order, return the minimum i such that nums[i] == i. If there’s no solution, return -1.
You are given a list of integers rooms and an integer target. Return the first integer in rooms that’s target or larger. If there is no solution, return -1.
You are given a list of integers nums. Return the number of pairs i < j such that nums[i] = nums[j].
You are given a list nums of length n + 1 picked from the range 1, 2, ..., n. By the pigeonhole principle, there must be a duplicate. Find and return it. The...
You are given a list of integers nums which contains at least one 1. Return whether all the 1s appear consecutively.
You are given a list of integers nums that used to be an arithmetic sequence. Given that a number was removed, and that the number was not the first or the l...
Given a two-dimensional integer matrix, sort each of the columns in ascending order.
Given a list of integers prices representing prices of cars for sale, and a budget k, return the maximum number of cars you can buy.
Given a list of integers nums, return the number of contiguous arithmetic sequences of length ≥ 3.
Given a list of integers nums, return whether you can rearrange the order of nums such that the difference between every consecutive two numbers is the same.
You are given a list of integers nums, representing a decimal number and nums[i] is between [0, 9].
You are given an integer n consisting of digits 1, 2, and 3 and you can flip one digit to a 3. Return the maximum number you can make.