随笔分类 - Array
摘要:Jump Game | Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represent
阅读全文
摘要:Given an unsorted array of integers, find the length of the longest consecutive elements sequence. Clarification Your algorithm should run in O(n) com
阅读全文
摘要:k Sum Given n distinct positive integers, integer k (k <= n) and a number target. Find k numbers where sum is target. Calculate how many solutions the
阅读全文
摘要:Single Number Given 2*n + 1 numbers, every numbers occurs twice except one, find it. Example Given [1,2,2,1,3,4,3], return 4 分析: 利用bit operator ^ 的特点即
阅读全文
摘要:Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers.
阅读全文
摘要:3 Sum Given an array S of n integers, are there elements a, b, c in Ssuch that a + b + c = 0? Find all unique triplets in the array which gives the su
阅读全文
摘要:Two Sum I Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of
阅读全文
摘要:Given a collection of distinct numbers, return all possible permutations. For example,[1,2,3] have the following permutations: [ [1,2,3], [1,3,2], [2,
阅读全文
摘要:For a given sorted array (ascending order) and a target number, find the first index of this number in O(log n) time complexity. If the target number
阅读全文
摘要:Find K-th largest element in an array. Notice You can swap elements in the array Example In array [9,3,2,4,8], the 3rd largest element is 4. In array
阅读全文
摘要:Merge two given sorted integer array A and B into a new sorted integer array. Merge two given sorted integer array A and B into a new sorted integer a
阅读全文
摘要:Given a rotated sorted array, recover it to sorted array in-place. Given a rotated sorted array, recover it to sorted array in-place. Given a rotated
阅读全文
摘要:Given an integers array A. Define B[i] = A[0] * ... * A[i-1] * A[i+1] * ... * A[n-1], calculate B WITHOUT divide operation. Example For A = [1, 2, 3],
阅读全文
摘要:Given two sorted integer arrays A and B, merge B into A as one sorted array. Notice You may assume that A has enough space (size that is greater or eq
阅读全文
摘要:Remove Duplicates from Sorted Array I Given a sorted array, remove the duplicates in place such that each element appear only once and return the new
阅读全文
摘要:560. Subarray Sum Equals K Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to
阅读全文
摘要:Find the contiguous subarray within an array (containing at least one number) which has the largest product. Example For example, given the array [2,3
阅读全文
摘要:Given a sorted (increasing order) array, Convert it to create a binary tree with minimal height. Example Given [1,2,3,4,5,6,7], return 4 / \ 2 6 / \ /
阅读全文
摘要:Given an array of n positive integers and a positive integer s, find the minimal length of a subarray of which the sum ≥ s. If there isn't one, return
阅读全文
摘要:Given a list of non-negative numbers and a target integer k, write a function to check if the array has a continuous subarray of size at least 2 that
阅读全文

浙公网安备 33010602011771号