ARTS #27 Algorithm 本周选择的算法题是:Search in Rotated Sorted Array 规则如下: Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., [0,1,2,4,5,6,7] might become [4,5,...
ARTS #26 Algorithm 本周选择的算法题是:Next Permutation 规则如下: Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possib...
ARTS #25 Algorithm 本周选择的算法题是:Remove Element 规则如下: Given an array nums and a value val, remove all instances of that value in-place and return the new length. Do not allocate extra space for another arra...
ARTS #24 Algorithm 本周选择的算法题是:4Sum 规则如下: Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c + d = target? Find all unique quadruplets in...
ARTS #23 Algorithm 本周选择的算法题是:Search Insert Position 规则如下: Given a sorted array 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 ...
ARTS #22 Algorithm 本周选择的算法题是:Longest Valid Parentheses 规则如下: Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring. Example ...
ARTS #21 Algorithm 本周选择的算法题是:Remove Duplicates From Sorted Array 规则如下: Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length. Do not...
ARTS #20 Algorithm 本周选择的算法题是:3Sum Closest 规则如下: Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three in...
ARTS #19 Algorithm 本周选择的算法题是:Container With Most Water 规则如下: Given n non-negative integers a1, a2, …, an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the tw...
ARTS #18 Algorithm 本周选择的算法题是:Subarrays with K Different Integers 规则如下: Given an array A of positive integers, call a (contiguous, not necessarily distinct) subarray of A good if the number of different i...