2015年3月22日

Validate Binary Search Tree

摘要: 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 sub... 阅读全文

posted @ 2015-03-22 21:04 zhouzhou0615 阅读(158) 评论(0) 推荐(0) 编辑

Word Ladder

摘要: Word Ladder问题:Given two words (startandend), and a dictionary, find the length of shortest transformation sequence fromstarttoend, such that:Only one ... 阅读全文

posted @ 2015-03-22 20:39 zhouzhou0615 阅读(123) 评论(0) 推荐(0) 编辑

(转)基于快速排序的TOPK算法

摘要: 基于快速排序的TOPK算法转自:http://blog.csdn.net/fanzitao/article/details/7617223思想:类似于快速排序,首先选择一个划分元,如果这个划分元的序号index刚好等于k,那么这个划分元以及左边的数,刚好组成了top-k small data;如果i... 阅读全文

posted @ 2015-03-22 16:37 zhouzhou0615 阅读(1618) 评论(0) 推荐(0) 编辑

Number of 1 Bits

摘要: Number of 1 Bits问题:Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as theHamming weight).For exa... 阅读全文

posted @ 2015-03-22 14:35 zhouzhou0615 阅读(162) 评论(0) 推荐(0) 编辑

Word Search

摘要: Word Search问题:Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell,... 阅读全文

posted @ 2015-03-22 14:26 zhouzhou0615 阅读(120) 评论(0) 推荐(0) 编辑

Rotate Array

摘要: Rotate Array问题:Rotate an array ofnelements to the right byksteps.For example, withn= 7 andk= 3, the array[1,2,3,4,5,6,7]is rotated to[5,6,7,1,2,3,4].思... 阅读全文

posted @ 2015-03-22 13:57 zhouzhou0615 阅读(148) 评论(0) 推荐(0) 编辑

Reverse Words in a String

摘要: 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".思路... 阅读全文

posted @ 2015-03-22 11:04 zhouzhou0615 阅读(105) 评论(0) 推荐(0) 编辑

导航