摘要:
Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. 阅读全文
摘要:
Description: Count the number of prime numbers less than a non-negative number, n. 找质数的问题. [http://www.cnblogs.com/li-daphne/p/5549557.html]我在这里有过分析 ! 阅读全文
摘要:
整型数组,元素有正数和负数。数组中一个或连续的多个整数组成一个子数组,求所有子数组中最大值。 动态规划, 状态转移方程,max[].size = nums.size() max[i]= max[i-1]+nums[i],if max[i-1]>0 nums[i], if max[i-1]<=0 这样 阅读全文
摘要:
剑指offer给出两类方法: 1,借助快排的思想,需要修改输入数组的元素,时间复杂度O(n) 2,借助STL中set或者multiset,因为它们的底层数据结构是红黑树实现的,插入数据时间复杂度为O(logk),所以总的时间复杂度为O(nlogn); 方法2的代码如下: 阅读全文
摘要:
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. 阅读全文
摘要:
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 阅读全文
摘要:
单例模式? 只能实现一个实例的类成为单例。 muduo库中单例模式实现 阅读全文
摘要:
题目:在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。 请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有这个整数? 思路:查找7 从右上角的数组开始判断:9>7,又因为每一列从上到下递增,所以这一列淘汰 接着第三列也被排除 现在右上角为2 阅读全文
摘要:
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 阅读全文
摘要:
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 阅读全文