摘要: 题目Given an integern, return the number of trailing zeroes inn!.Note:Your solution should be in logarithmic time complexity.分析Note中提示让用对数的时间复杂度求解,那么如果粗... 阅读全文
posted @ 2015-05-11 11:19 xlturing 阅读(659) 评论(0) 推荐(0) 编辑
摘要: Given a list of non negative integers, arrange them such that they form the largest number.For example, given[3, 30, 34, 5, 9], the largest formed num... 阅读全文
posted @ 2015-05-03 12:48 xlturing 阅读(2099) 评论(0) 推荐(0) 编辑
摘要: 在Java位运算总结-leetcode题目博文中总结了Java提供的按位运算操作符,今天又碰到LeetCode中一道按位操作的题目Given a range [m, n] where 0 0 || n > 0) { 8 if ((m & 1) == (n & 1)) { 9... 阅读全文
posted @ 2015-04-29 16:41 xlturing 阅读(523) 评论(0) 推荐(0) 编辑
摘要: Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two nu... 阅读全文
posted @ 2015-04-29 09:30 xlturing 阅读(525) 评论(0) 推荐(0) 编辑
摘要: Description:Count the number of prime numbers less than a non-negative number,nclick to show more hints.Credits:Special thanks to@mithmattfor adding t... 阅读全文
posted @ 2015-04-28 21:21 xlturing 阅读(649) 评论(0) 推荐(0) 编辑
摘要: 快速排序,只要学习过编程的人肯定都听说过这个名词,但是有时候写的时候还真蒙住了,网上搜罗了下以及查阅了"introduction to algorithm",暂时找到两种实现快排的方式,记录如下:1.通过挖坑,分治的方式,需要左右交替遍历思想如下:代码实现: 1 public static ... 阅读全文
posted @ 2015-04-28 10:56 xlturing 阅读(1657) 评论(0) 推荐(0) 编辑
摘要: 题目如下:题目给出的例子不太好,容易让人误解成不断顺着右节点访问就好了,但是题目意思并不是这样。换成通俗的意思:按层遍历二叉树,输出每层的最右端结点。这就明白时一道二叉树层序遍历的问题,用一个队列来处理,但是问题是怎么来辨别每层的最右端结点,我思考了半天,最后想出的办法是利用一个标记位,例如上面的例... 阅读全文
posted @ 2015-04-26 23:24 xlturing 阅读(1065) 评论(0) 推荐(0) 编辑
摘要: 【Java心得总结六】Java容器中——Collection在前面自己总结的一篇博文中对Collection的框架结构做了整理,这里深究一下Java中list的实现方式1.动态数组Incomputer science, adynamic array,growable array,resizable ... 阅读全文
posted @ 2015-04-23 14:39 xlturing 阅读(896) 评论(0) 推荐(0) 编辑
摘要: 题目:House RobberYou are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constra... 阅读全文
posted @ 2015-04-22 16:45 xlturing 阅读(456) 评论(0) 推荐(0) 编辑
摘要: 【Java心得总结七】Java容器下——Map在自己总结的这篇文章中有提到hashCode,但是没有细究,今天细究整理一下hashCode相关问题1.hashCode与equals 首先我们都知道hashCode()和equals()函数是java基类Object的一部分,我查阅了java7文档,... 阅读全文
posted @ 2015-04-21 21:36 xlturing 阅读(3683) 评论(0) 推荐(1) 编辑