摘要: Given an integer, write a function to determine if it is a power of two.method:1. recursive:if x % 2 != 0, return false;if x == 0, return false;if x =... 阅读全文
posted @ 2015-07-08 18:01 huj690 阅读(151) 评论(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"]. 1 class ... 阅读全文
posted @ 2015-06-27 18:39 huj690 阅读(150) 评论(0) 推荐(0) 编辑
摘要: Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1Trivia:This problem was inspired bythis... 阅读全文
posted @ 2015-06-13 21:31 huj690 阅读(176) 评论(0) 推荐(0) 编辑
摘要: Given an array of integers and an integerk, find out whether there there are two distinct indicesiandjin the array such thatnums[i] = nums[j]and the d... 阅读全文
posted @ 2015-06-08 23:37 huj690 阅读(135) 评论(0) 推荐(0) 编辑
摘要: Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the arr... 阅读全文
posted @ 2015-06-08 23:27 huj690 阅读(132) 评论(0) 推荐(0) 编辑
摘要: Reverse a singly linked list.思路:to slove this problem, I choose a recurrent method, to reverse linked-list nodes one-by-one.first, point head to NULL.... 阅读全文
posted @ 2015-06-08 23:21 huj690 阅读(263) 评论(0) 推荐(0) 编辑
摘要: Given two stringssandt, determine if they are isomorphic.Two strings are isomorphic if the characters inscan be replaced to gett.All occurrences of a ... 阅读全文
posted @ 2015-06-08 22:16 huj690 阅读(131) 评论(0) 推荐(0) 编辑
摘要: Given acompletebinary tree, count the number of nodes.Definition of a complete binary tree fromWikipedia:In a complete binary tree every level, except... 阅读全文
posted @ 2015-06-08 21:30 huj690 阅读(298) 评论(0) 推荐(0) 编辑
摘要: Find the total area covered by tworectilinearrectangles in a2Dplane.Each rectangle is defined by its bottom left corner and top right corner as shown ... 阅读全文
posted @ 2015-06-08 15:16 huj690 阅读(278) 评论(0) 推荐(0) 编辑
摘要: python白皮书(11)—字符编码1、unicode编码世界上存在着多种编码方式,同一个二进制数字可以被解释成不同的符号。因此,要想打开一个文本文件,不但要知道它的编码方式,还要安装有对应编码表,否则就可能无法读取或出现乱码。为什么电子邮件和网页都经常会出现乱码,就是因为信息的提供者和信息的读取者... 阅读全文
posted @ 2013-04-23 10:26 huj690 阅读(226) 评论(0) 推荐(0) 编辑