Find K Closest Elements - LeetCode
Given a sorted integer array arr
, two integers k
and x
, return the k
closest integers to x
in the array. The result should also be sorted in ascending order.
Intersection of Two Arrays - LeetCode
Given two integer arrays nums1
and nums2
, return an array of their intersection. Each element in the result must be unique and you may return the result in any order.
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
.
Minimum Size Subarray Sum - LeetCode
Given an array of positive integers nums
and a positive integer target
, return the minimal length of a subarray whose sum is greater than or equal to target
. If there is no such subarray, return 0
instead.
Repeated DNA Sequences - LeetCode
The DNA sequence is composed of a series of nucleotides abbreviated as 'A'
, 'C'
, 'G'
, and 'T'
.
Longest Substring Without Repeating Characters - LeetCode
Given a string s
, find the length of the longest substring without repeating characters.
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.
Longest Substring with At Least K Repeating Characters - LeetCode
Given a string s
and an integer k
, return the length of the longest substring of s
such that the frequency of each character in this substring is greater than or equal to k
.
Search Insert Position - LeetCode
Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.
…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 are given an m x n
integer matrix matrix
with the following two properties:
Length of Last Word - LeetCode
Given a string s
consisting of words and spaces, return the length of the last word in the string.
A word is a maximal substring consisting of non-space characters only.
Roman numerals are represented by seven different symbols: I
, V
, X
, L
, C
, D
and M
.
Remove Duplicates from Sorted Array || - LeetCode
Given an integer array nums
sorted in non-decreasing order, remove some duplicates in-place such that each unique element appears at most twice. The relative order of the elements should be kept the same.
Best Time to Buy and Sell Stock - LeetCode
You are given an array prices
where prices[i]
is the price of a given stock on the ith
day.
Given an integer array nums
, rotate the array to the right by k
steps, where k
is non-negative.
Remove Duplicates from Sorted Array - LeetCode
Given an integer array nums
sorted in non-decreasing order, remove the duplicates in-place such that each unique element appears only once. The relative order of the elements should be kept the same. Then return the number of unique elements in nums
.
Given an integer array nums
and an integer val
, remove all occurrences of val
in nums
in-place. The order of the elements may be changed. Then return the number of elements in nums
which are not equal to val
.
You are given two integer arrays nums1
and nums2
, sorted in non-decreasing order, and two integers m
and n
, representing the number of elements in nums1 and nums2 respectively.
Next Greater Element I - LeetCode
The next greater element of some element x
in an array is the first greater element that is to the right of x in the same array.