- 博客(6)
- 资源 (2)
- 收藏
- 关注
原创 lintcode:二分查找
二分查找 lintcode二分查找 给定一个排序的整数数组(升序)和一个要查找的整数target,用O(logn)的时间查找到target第一次出现的下标(从0开始),如果target不存在于数组中,返回-1。 样例 在数组 [1, 2, 3, 3, 4, 5, 10] 中二分查找3,返回2。class Solution {public: /** ...
2016-08-30 22:43:24 1036 2
原创 二叉树的所有路径
二叉树的所有路径/** * Definition of TreeNode: * class TreeNode { * public: * int val; * TreeNode *left, *right; * TreeNode(int val) { * this->val = val; * this->left = this-
2016-08-24 00:40:59 373
原创 lintcode:x的平方根
x的平方根lintcode 题目链接class Solution {public: /** * @param x: An integer * @return: The sqrt of x */ int binary_search(long l,long r, long &x){ while(l<=r) {
2016-08-23 22:45:24 426
原创 Reorder array to construct the minimum number
Reorder array to construct the minimum numberlintcode题目链接1.O(n)Log(n)时间复杂度 直接贴代码。class Solution {public: /** * @param nums n non-negative integer array * @return a string */
2016-08-23 14:39:33 777
原创 3 Sum问题
3 Sum 问题题目链接:lintcode 3 sum (http://www.lintcode.com/en/problem/3sum/)基本思路 一会写代码块具体实现如下:class Solution {public: /** * @param numbers : Give an array numbers of n integer * @return
2016-08-03 23:14:02 523
原创 子数组之和
蛮力法时间复杂度O(N2).vector<int> subarraySum(vector<int> nums){ // write your code here vector<int> res; int i,j,sum; for(i=0;i<nums.size();i++) { sum=nums[
2016-08-01 23:31:18 287
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人