Spurs

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 :: 管理 ::

随笔分类 -  Leetcode

上一页 1 2 3 4 下一页

摘要:有一个升序排序的数组. For example, Given sorted array , Your function should return length = , with the first five elements of nums being . It doesn't matter wh 阅读全文
posted @ 2017-08-28 21:19 英雄与侠义的化身 阅读(116) 评论(0) 推荐(0)

摘要:Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., might become ). Write a function to determine if 阅读全文
posted @ 2017-08-28 16:51 英雄与侠义的化身 阅读(138) 评论(0) 推荐(0)

摘要:Given an integer $n$, generate a square matrix filled with elements from 1 to $n^2$ in spiral order. For example, Given n = 3, You should return the f 阅读全文
posted @ 2017-08-27 11:14 英雄与侠义的化身 阅读(106) 评论(0) 推荐(0)

摘要:Given an array of non negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maxim 阅读全文
posted @ 2017-08-26 17:00 英雄与侠义的化身 阅读(122) 评论(0) 推荐(0)

摘要:Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. For example, Given the following matrix: You 阅读全文
posted @ 2017-08-26 15:38 英雄与侠义的化身 阅读(86) 评论(0) 推荐(0)

摘要:You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Follow up: Could you do this in place? 方阵顺时针旋转90度, 阅读全文
posted @ 2017-08-24 12:58 英雄与侠义的化身 阅读(107) 评论(0) 推荐(0)

摘要:Given an array of integers sorted in ascending order, find the starting and ending position of a given target value. Your algorithm's runtime complexi 阅读全文
posted @ 2017-08-22 19:05 英雄与侠义的化身 阅读(119) 评论(0) 推荐(0)

摘要:Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array whic 阅读全文
posted @ 2017-08-22 12:12 英雄与侠义的化身 阅读(101) 评论(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 @ 2017-08-22 10:44 英雄与侠义的化身 阅读(109) 评论(0) 推荐(0)

摘要:Given an unsorted integer array, find the first missing positive integer. For example , Your algorithm should run in $O(n)$ time and uses constant spa 阅读全文
posted @ 2017-08-21 18:19 英雄与侠义的化身 阅读(115) 评论(0) 推荐(0)

摘要:Given an array of integers, (n = size of array), some elements appear twice and others appear once . Find all the elements that appear twice in this a 阅读全文
posted @ 2017-08-21 11:55 英雄与侠义的化身 阅读(121) 评论(0) 推荐(0)

摘要:Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., might become ). You are given a target value to 阅读全文
posted @ 2017-08-20 12:10 英雄与侠义的化身 阅读(144) 评论(0) 推荐(0)

摘要:Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted f 阅读全文
posted @ 2017-08-19 18:43 英雄与侠义的化身 阅读(145) 评论(0) 推荐(0)

摘要:Given a matrix, if an element is , set its entire row and column to . Do it in place. 重点是空间复杂度限制为常数. 人家想法: 用 matrix 的第0行和第0列的元素分别记录所对应的行和列是否有0. 比较特殊,我 阅读全文
posted @ 2017-08-19 12:19 英雄与侠义的化身 阅读(127) 评论(0) 推荐(0)

摘要:Given an array of integers, are there elements in such that ? Find all unique triplets in the array which gives the sum of zero. Note: The solution se 阅读全文
posted @ 2017-08-18 21:49 英雄与侠义的化身 阅读(130) 评论(0) 推荐(0)

摘要:给一个非负数组A,元素们是A[i], i=0,...,n 1. 索引i代表x坐标,值A[i]表示高度.索引i与A[i],既(i, A[i])表示了垂直于x轴的线段. 请找出两条线段,与x轴组成的桶最多能装多少水? 人家想法: 先从底最宽搜起.两个边找最矮的移动,计算容积,保留最大值,循环条件 lef 阅读全文
posted @ 2017-08-17 23:12 英雄与侠义的化身 阅读(102) 评论(0) 推荐(0)

摘要:Follow up for "153. Find Minimum in Rotated Sorted Array": What if duplicates are allowed? Would this affect the run time complexity? How and why? Sup 阅读全文
posted @ 2017-08-17 12:31 英雄与侠义的化身 阅读(98) 评论(0) 推荐(0)

摘要:Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., might become ). Find the minimum element. You ma 阅读全文
posted @ 2017-08-16 18:23 英雄与侠义的化身 阅读(92) 评论(0) 推荐(0)

摘要:Suppose you have a long flowerbed in which some of the plots are planted and some are not. However, flowers cannot be planted in adjacent plots they w 阅读全文
posted @ 2017-08-16 16:44 英雄与侠义的化身 阅读(105) 评论(0) 推荐(0)

摘要:Given an integer array, find three numbers whose product is maximum and output the maximum product. Example 1: Example 2: Note: 1. The length of the g 阅读全文
posted @ 2017-08-15 17:42 英雄与侠义的化身 阅读(108) 评论(0) 推荐(0)

上一页 1 2 3 4 下一页