积少成多

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

2016年6月23日

摘要: 整型数组,元素有正数和负数。数组中一个或连续的多个整数组成一个子数组,求所有子数组中最大值。 动态规划, 状态转移方程,max[].size = nums.size() max[i]= max[i-1]+nums[i],if max[i-1]>0 nums[i], if max[i-1]<=0 这样 阅读全文
posted @ 2016-06-23 21:58 x7b5g 阅读(187) 评论(0) 推荐(0)

摘要: 剑指offer给出两类方法: 1,借助快排的思想,需要修改输入数组的元素,时间复杂度O(n) 2,借助STL中set或者multiset,因为它们的底层数据结构是红黑树实现的,插入数据时间复杂度为O(logk),所以总的时间复杂度为O(nlogn); 方法2的代码如下: 阅读全文
posted @ 2016-06-23 21:46 x7b5g 阅读(204) 评论(0) 推荐(0)

摘要: 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. 阅读全文
posted @ 2016-06-23 21:30 x7b5g 阅读(147) 评论(0) 推荐(0)

摘要: There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity sh 阅读全文
posted @ 2016-06-23 21:18 x7b5g 阅读(208) 评论(0) 推荐(0)

摘要: 单例模式? 只能实现一个实例的类成为单例。 muduo库中单例模式实现 阅读全文
posted @ 2016-06-23 20:52 x7b5g 阅读(183) 评论(0) 推荐(0)

摘要: 题目:在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。 请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有这个整数? 思路:查找7 从右上角的数组开始判断:9>7,又因为每一列从上到下递增,所以这一列淘汰 接着第三列也被排除 现在右上角为2 阅读全文
posted @ 2016-06-23 20:03 x7b5g 阅读(198) 评论(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 @ 2016-06-23 19:38 x7b5g 阅读(111) 评论(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 @ 2016-06-23 18:42 x7b5g 阅读(168) 评论(0) 推荐(0)

摘要: Find all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used and each combination should be 阅读全文
posted @ 2016-06-23 11:10 x7b5g 阅读(184) 评论(0) 推荐(0)

摘要: Given a sorted integer array without duplicates, return the summary of its ranges. For example, given [0,1,2,4,5,7], return ["0->2","4->5","7"]. Credi 阅读全文
posted @ 2016-06-23 10:27 x7b5g 阅读(142) 评论(0) 推荐(0)

摘要: c++11中提供了to_string函数,定义在string中, 重载了一大片, 另外,标准库中string有一批函数,特别难用. 阅读全文
posted @ 2016-06-23 10:23 x7b5g 阅读(387) 评论(0) 推荐(0)