随笔分类 -  Array

上一页 1 ··· 5 6 7 8 9 10 下一页
摘要: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 阅读全文
posted @ 2016-07-05 03:18 北叶青藤 阅读(179) 评论(0) 推荐(0)
摘要:Given an unsorted array of integers, find the length of the longest consecutive elements sequence. Clarification Your algorithm should run in O(n) com 阅读全文
posted @ 2016-07-05 01:48 北叶青藤 阅读(185) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2016-07-05 00:55 北叶青藤 阅读(249) 评论(0) 推荐(0)
摘要: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 ^ 的特点即 阅读全文
posted @ 2016-07-04 11:27 北叶青藤 阅读(165) 评论(0) 推荐(0)
摘要: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. 阅读全文
posted @ 2016-07-04 10:30 北叶青藤 阅读(216) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2016-07-04 07:24 北叶青藤 阅读(239) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2016-07-04 07:13 北叶青藤 阅读(326) 评论(0) 推荐(0)
摘要: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, 阅读全文
posted @ 2016-07-04 05:29 北叶青藤 阅读(242) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2016-07-04 01:22 北叶青藤 阅读(245) 评论(0) 推荐(0)
摘要: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  阅读全文
posted @ 2016-07-02 12:03 北叶青藤 阅读(163) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2016-07-02 09:59 北叶青藤 阅读(217) 评论(0) 推荐(0)
摘要: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  阅读全文
posted @ 2016-07-02 09:52 北叶青藤 阅读(175) 评论(0) 推荐(0)
摘要: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], 阅读全文
posted @ 2016-07-01 11:05 北叶青藤 阅读(373) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2016-07-01 10:41 北叶青藤 阅读(146) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2016-07-01 08:49 北叶青藤 阅读(156) 评论(0) 推荐(0)
摘要: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  阅读全文
posted @ 2016-07-01 07:57 北叶青藤 阅读(228) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2016-07-01 05:44 北叶青藤 阅读(201) 评论(0) 推荐(0)
摘要: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 / \ / 阅读全文
posted @ 2016-07-01 05:31 北叶青藤 阅读(230) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2016-07-01 05:23 北叶青藤 阅读(150) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2016-07-01 04:55 北叶青藤 阅读(162) 评论(0) 推荐(0)

上一页 1 ··· 5 6 7 8 9 10 下一页