- 博客(34)
- 资源 (29)
- 收藏
- 关注
原创 【Leet Code】55. Jump Game---Medium
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 maximum jump length at that position.Determine i
2015-11-30 16:14:23
300
原创 【Leet Code】229. Majority Element II---Medium
Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. The algorithm should run in linear time and in O(1) space.Hint:How many majority elements could it po
2015-11-30 14:44:34
255
原创 【Leet Code】152. Maximum Product Subarray---Medium
Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array [2,3,-2,4],the contiguous subarray [2,3] has the larges
2015-11-26 15:38:57
313
原创 【Leet Code】53. Maximum Subarray---Medium
Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [−2,1,−3,4,−1,2,1,−5,4],the contiguous subarray [4,−1,2,1] ha
2015-11-26 11:07:10
304
原创 【Leet Code】64. Minimum Path Sum---Medium
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note: You can only move either down or right at
2015-11-23 18:16:00
492
原创 【Leet Code】209. Minimum Size Subarray Sum---Medium
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 0 instead.For example, given the array [2,3
2015-11-23 15:25:05
282
原创 【Leet Code】268. Missing Number---Medium
Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array.For example,Given nums = [0, 1, 3] return 2.Note:Your algorithm sho
2015-11-23 13:28:37
310
原创 【Leet Code】283. Move Zeroes---Easy
Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.For example, given nums = [0, 1, 0, 3, 12], after calling you
2015-11-23 10:45:46
240
原创 【Leet Code】31. Next Permutation---Medium
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest possible
2015-11-20 15:36:04
309
原创 【Leet Code】238. Product of Array Except Self---Medium
Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i].Solve it without division and in O
2015-11-18 16:14:27
340
原创 【Leet Code】80. Remove Duplicates from Sorted Array II---Medium
Follow up for "Remove Duplicates":What if duplicates are allowed at most twice?For example,Given sorted array nums = [1,1,1,2,2,3],Your function should return length = 5, with the first fi
2015-11-18 15:20:30
285
原创 【Leet Code】26. Remove Duplicates from Sorted Array---Easy
Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this in place with
2015-11-18 14:58:24
290
原创 【Leet Code】48. Rotate Image---Medium
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?思路:该题目最大的难点就是理清二维数组的转换。对二维数组每圈每圈的处理(或者说一层一层的转)。理清
2015-11-18 14:52:45
311
原创 【Leet Code】74. Search a 2D Matrix---Medium
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 from left to right.The first integer of each
2015-11-17 17:03:57
338
原创 【Leet Code】34. Search for a Ranged---Medium
Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the order of O(log n).If the target is not found
2015-11-17 16:10:06
334
原创 【Leet Code】81. Search in Rotated Sorted Array II---Medium
Follow up for "Search in Rotated Sorted Array":What if duplicates are allowed?Would this affect the run-time complexity? How and why?Write a function to determine if a given target is in the
2015-11-17 10:29:16
278
原创 【Leet Code】33. Search in Rotated Sorted Array---Hard
Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target value to search. If found in the array retur
2015-11-16 17:51:52
258
原创 【Leet Code】35. Search Insert Position---Medium
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 in order.You may assume no duplicates in the array.
2015-11-16 16:49:42
269
原创 【Leet Code】73. Set Matrix Zeroes---Medium
Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.click to show follow up.Follow up:Did you use extra space?A straight forward solution using O(m
2015-11-10 11:10:10
488
原创 【Leet Code】59. Spiral Matrix II---Medium
Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.For example,Given n = 3,You should return the following matrix:[ [ 1, 2, 3 ], [ 8, 9, 4 ], [
2015-11-05 11:18:12
281
原创 【Leet Code】54. Spiral Matrix---Medium
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:[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ]]
2015-11-05 10:35:37
305
原创 【Leet Code】164. Maximum Gap---Hard
Given an unsorted array, find the maximum difference between the successive elements in its sorted form.Try to solve it in linear time/space.Return 0 if the array contains less than 2 elements
2015-11-02 15:49:54
419
原创 【Leet Code】56. Merge Intervals---Hard
Given a collection of intervals, merge all overlapping intervals.For example,Given [1,3],[2,6],[8,10],[15,18],return [1,6],[8,10],[15,18].思路:刚看到这个题目没看懂什么意思,先对题目进行说明:对以两个数对为元素的数组(
2015-10-29 11:47:10
284
原创 【Leet Code】274. H-Index---Medium
Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index.According to the definition of h-index on Wikipedia: "A
2015-10-29 10:46:17
369
原创 【Leet Code】148. Sort List---Medium
Sort a linkedlist in O(n log n) time using constant space complexity.思路:借助2-路归并排序实现。基本思想:归并排序(Merging Sort)法是将两个(或两个以上)有序表合并成一个新的有序表,即把待排序序列分为若干个子序列,每个子序列是有序的。然后再把有序子序列合并为整体有序序列。时间复杂度:O(nl
2015-09-15 16:13:00
380
原创 【Leet Code】147. Insertion Sort List---Medium
Sort a linkedlist using insertion sort.思路: 插入排序主要有直接插入排序和希尔插入排序,1) 直接插入排序把一个记录插入到一个已经排好序的有序表中,从而得到一个新的,记录数增1的有序表。时间复杂度: O(n^2), 空间复杂度:O(1)。稳定排序算法。图示:2)希尔排序,又称“缩小增量排序”。先将整个待排记录序列分割成若干
2015-09-15 16:08:25
351
原创 【Leet Code】 75.Sort Colors--medium
Given anarray with n objects colored red, white or blue, sort them so thatobjects of the same color are adjacent, with the colors in the order red, whiteand blue.Here, we will use the integers 0, 1,
2015-09-15 16:06:40
336
原创 【Leet Code】 242. Valid Anagram--easy
Given twostrings s and t, write a function to determine if t isan anagram of s.For example,s = "anagram", t = "nagaram", return true.s = "rat", t = "car", return false.Note:You may assume th
2015-09-15 16:04:50
328
原创 排序算法小结
注:本文参考了文章http://blog.youkuaiyun.com/hguisu/article/details/7776068,按照自己的理解另写了一篇。概述排序算法主要分为内排和外排,内部排序是指待排序记录放在计算机随机存储器中进行待排序过程;外部排序指待排序记录的数据量非常大,以致内存一次不能容纳全部记录,在排序过程中需要对外存访问的排序过程。此处仅讨论内部排序。排序的主要算
2015-08-16 12:20:44
374
转载 extern "C"的用法
原文链接: http://blog.youkuaiyun.com/iitvip/article/details/8618192(1)在C++中引用C语言中的函数和变量,在包含C语言头文件(假设为cExample.h)时,需进行下列处理:extern "C"{#i nclude "cExample.h"}而在C语言的头文件中,对其外部函数只能指定为extern类型,C语言中不支持exte
2015-08-15 17:47:40
297
原创 C++ 11新特性笔记-1: 保证稳定性和兼容性
主要描述了17个基本的新特性:新特性1:预定义宏表:C++11中与c99兼容的宏宏名称功能描述__STDC_HOSTED__如果编译器的目标系统环境中包含完整的标准C库,则该宏就定义为1;否则宏的值为0.__STDC__C编译器通常用这个宏的值表示编译器的实现是否和C标准一致。C++11标准中这
2015-08-06 18:21:09
496
转载 linux下C/C++IDE比较——Code::Blocks
转载请注明出处:编程笔记BLOG工欲善其事,必先利其器。用了这么久的linux,现在比较主流的几个C/C++的IDE基本已都用过了,现在来对他们做一下简单的比较。1、VIM首先要说的是VIM。我认为,VIM只是一个编辑器,不能算是IDE。虽说VIM有很多插件,例如代码折叠、递进等,可以将VIM组建成几乎类似一个IDE,但始终它不是专门的IDE,所以在功能支持上还是远不如那些专门的IDE如:ecli
2010-04-15 20:47:00
469
转载 Fedora Linux 下安装配置C开发环境Code::Blocks
一、提前的话 要说C语言和Linux的关系大家应该都不会陌生,Linux系统内核就是用C语言开发的,所以所有的Linux系统下面 都会有C的编译调试工具,不过这些工具都是命令式的,正式开发的话会很不方便。Fedora在安装的时候可以选择安装Fedora Eclipse,这个IDE很强大,C,C++,Java,Python等等都支持,而且编译,调试和测试等功能也很完善。不过一般太强大的东西都有
2010-04-15 18:42:00
799
原创 linux下rar格式文件解压方法(ubuntu9下菜鸟级方法)
最近刚接触linux ,对这个系统是一点都不了解,但是由于网上下载的资源多是.rar格式的,所以如何解压这个文件是我遇到的一个难题。在网上搜了些相关方法,原文如下:Linux系统中rar、unrar命令安装和使用详解作者:Van说明:由于本人水平有限,难免有错误之处。欢迎转载,但请注明作者信息。安装:如果是以tarball形式安装安装,去ra
2010-04-14 11:21:00
1361
iPhone开发基础教程_2009.04_(美)Dave Mark, Jeff LaMarche著_人民邮电出版社_12194396.pdf
2015-03-17
Exchange+Server+2007从入门到精通.pdf
2010-09-01
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人