- 博客(88)
- 资源 (1)
- 收藏
- 关注
原创 Reverse Linked List
Reverse a singly linked list.解析:/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class
2015-05-06 13:43:10 351
原创 Rotate Array
Rotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4].class Solution {public: void rotate(int n
2015-05-01 13:16:40 330
原创 【Leetcode长征系列】Letter Combinations of a Phone Number
原题:Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.Input
2014-08-21 17:14:35 805
原创 【Leetcode长征系列】Construct Binary Tree from Inorder and Postorder Traversal
原题:Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.思路:和上一题一样,后续我们可以通过最后一个值得到根的值,同样可以通过定位根的值得到左右子树的
2014-08-21 15:03:07 582
原创 【Leetcode长征系列】Construct Binary Tree from Preorder and Inorder Traversal
原题:Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.思路:通过先序我们可以找到根节点,再到中序序列中去找到根节点,根节点的左边便为左子树,右边为右子
2014-08-21 14:54:06 749
原创 【Leetcode长征系列】Single Number II
原题:Given an array of integers, every element appears three times except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it withou
2014-08-15 11:47:09 623
原创 【Leetcode长征系列】Merge k Sorted Lists
原题:Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.思路:两条两条地合并。时间复杂度为O(n),n为所有链表节点和。代码:/** * Definition for singly-linked list. * struct List
2014-08-14 16:49:15 983 2
原创 【Leetcode长征系列】Sqrt(x)
原题:Implement int sqrt(int x).Compute and return the square root of x.==============================以下为引用====================================牛顿迭代法 为了方便理解,就先以本题为例: 计算x2 = n的解,令f(
2014-08-14 14:58:58 992
原创 c++数据类型
char -128 ~ +127 (1 Byte)short -32767 ~ + 32768 (2 Bytes)unsigned short 0 ~ 65536 (2 Bytes)long == intint -2147483648 ~ +2147483647
2014-08-14 13:54:05 506
原创 【Leetcode长征系列】Pow(x, n)
原题:Implement pow(x, n).思路:递归计算pow。class Solution {public: double pow(double x, int n) { long long int mid = n/2; int d = n%2; if(n==0) return 1; if(n==1) return
2014-08-14 13:53:10 776
原创 Maven学习资源
学习parquet过程中发现这尼玛和以前搭的架构都好不一样啊不是靠配置的是要用maven编译的!所以就又开始学习maven的漫漫长路…它官网里的解释我没太明白,官网里的样例也失败了,总之就是在自己找野路子学习了。而且现在发现真的是得自己尝试过了以后才能理解某些工具==============================================================
2014-08-13 15:20:50 515
原创 【Leetcode长征系列】Convert Sorted List to Binary Search Tree
原题:Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.思路:和处理数组的思想类似,用递归。代码:
2014-08-12 11:23:35 601 4
原创 【Leetcode长征系列】Longest Common Prefix
原题:Write a function to find the longest common prefix string amongst an array of strings.思路:pre赋给第一个strs值
2014-08-11 16:52:09 706
翻译 The striping and assembly algorithms from the Dremel paper( from github, project parquet-mr )
为了理解Dremel论文中给出的案例,笔者觉得对定义级别和重复级别这两个概念进行注释加强理解是有必要的,具体可以看Dremel那篇论文的图2和图3。柱状数据的嵌套模式:论文使用了以下的模型:message Document { required int64 DocId; optional group Links {
2014-08-11 14:03:50 1578
原创 【Leetcode长征系列】Convert Sorted Array to Binary Search Tree
原题:Given an array where elements are sorted in ascending order, convert it to a height balanced BST.【复习时间】:平衡二叉树(Balanced Binary Tree)具有以下性质:它是一棵空树或它的左右两个子树的高度差的绝对值不超过1,并且左右两个子树都是一棵平衡二叉树。常用算
2014-08-11 10:15:11 541
原创 【Leetcode长征系列】Evaluate Reverse Polish Notation
原题:Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or another expression.Some examples: ["2", "1",
2014-08-10 20:45:13 506
原创 【Leetcode长征系列】Add Binary
原题:Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".
2014-08-10 19:45:45 977
原创 【Leetcode长征系列】Best Time to Buy and Sell Stock
原题:Say you have an array for which the ith element is the price of a given stock on dayi.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the s
2014-08-10 17:51:55 732
原创 【Leetcode长征系列】Reverse Words in a String
原题:Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".Clarification:What constitutes a word?A sequence of non-s
2014-08-10 16:34:51 476
原创 【Leetcode长征系列】Unique Binary Search Trees II
原题:Given n, generate all structurally unique BST's (binary search trees) that store values 1...n.For example,Given n = 3, your program should return all 5 unique BST's shown below. 1
2014-08-10 16:07:30 522
原创 【Leetcode长征系列】Symmetric Tree
原题:Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \3 4 4 3But the fo
2014-08-10 11:09:45 501
翻译 Dremel: Interactive Analysis of Web-Scale Datasets 1~6节算法思想部分翻译
Dremel是一个具有可扩展性和交互性,专用于分析只读嵌套数据的查询系统。它本身对多级操作数和柱状数据布局的融合使它得以在秒级的反应时间内对有万亿数量级行记录的表进行集成语句查询。这个系统在谷歌包含数以千计的CPU和PT级的数据量,并有着上千名使用者。这篇论文将会介绍Dremel的体系结构以及其实现,并阐述它如何实现基于MapReduce的计算。本文将呈现一种全新的嵌套式数据柱状存储方式并通过一个基于几千节点的样例系统实验分析性能。
2014-08-08 12:49:46 1559
原创 【Leetcode长征系列】Length of Last Word
原题:Given a string s consists of upper/lower-case alphabets and empty space characters' ', return the length of last word in the string.If the last word does not exist, return 0.Note: A word
2014-08-08 10:56:19 599
原创 【Leetcode长征系列】Validate Binary Search Tree
原题:Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keys less than the node's k
2014-08-06 13:19:34 670
原创 【Leetcode长征系列】Path Sum II
原题:Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tree and sum = 22, 5 / \
2014-08-04 12:00:32 524
原创 【Leetcode长征系列】Remove Duplicates from Sorted List II
原题:Given a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinct numbers from the original list.For example,Given 1->2->3->3->4->4->5, return 1->2->5.Given
2014-08-03 19:52:05 490
原创 【Leetcode长征系列】Valid Sudoku
原题:Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character'.'.A partially f
2014-08-03 17:11:19 464
原创 【Leetcode长征系列】Longest Consecutive Sequence
原题:Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given [100, 4, 200, 1, 3, 2],The longest consecutive elements sequence is [1,
2014-08-03 17:00:26 716
原创 【Leetcode长征系列】Flatten Binary Tree to Linked List
原题:Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened tree should look like: 1
2014-08-03 15:37:13 470
原创 【Leetcode长征系列】Unique Paths II
原题:Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space is marked as 1 and 0 respectively in the g
2014-08-03 15:24:29 498
原创 【Leetcode长征系列】Insertion Sort List
原题:Sort a linked list using insertion sort.知识把
2014-08-01 14:18:08 543
原创 【Leetcode长征系列】Valid Palindrome
原题:Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Panama" is a palindrome."race a car" is n
2014-08-01 12:14:09 720
原创 【读书笔记】Mining of massive datasets
For clustering computing, the file system must also be different from thos
2014-07-31 15:54:24 669
原创 【Leetcode长征系列】Palindrome Number
原型:Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Some hints:Could negative integers be palindromes? (ie, -1)If you are thinking of conver
2014-07-31 12:02:20 816 5
原创 【Leetcode长征系列】Valid Parentheses
原题:Say you have an array for which the ith element is the price of a given stock on dayi.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the s
2014-07-30 15:24:23 629
原创 【Leetcode长征系列】Minimum Depth of Binary Tree
原题:Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.思路:深度优先
2014-07-30 14:48:01 633
原创 【Leetcode长征系列】 Divide Two Integers
原题:Divide two integers without using multiplication, division and mod operator.思路: 记录除数与被除数的符号跑
2014-07-30 14:32:01 653 1
原创 【Leetcode长征系列】Sum Root to Leaf Numbers
原题:Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which represents the number123.Find the to
2014-07-30 13:54:24 517
原创 【Leetcode长征系列】Plus One
原题:Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant digit is at the head of the list.思路:
2014-07-29 15:44:35 643
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人