上一页 1 ··· 4 5 6 7 8 9 10 下一页
摘要: Sort a linked list in O(n log n) time using constant space complexity.这道题属于人生中第一次对链表进行操作,首先,不同于C++中的struct,java中可以用一个类来定义一个数据结构。这道题一看没有任何思路,就看别人的代码,发现... 阅读全文
posted @ 2015-04-11 21:33 niuer++ 阅读(136) 评论(0) 推荐(0) 编辑
摘要: Implement int sqrt(int x).Compute and return the square root of x.这道题也属于二分查找的变形主流的方法是用牛顿插值,牛顿法的思想参考http://blog.csdn.net/StarCXDJ/article/details/18051... 阅读全文
posted @ 2015-04-11 21:26 niuer++ 阅读(98) 评论(0) 推荐(0) 编辑
摘要: Follow up for "Search in Rotated Sorted Array":What ifduplicatesare allowed?Would this affect the run-time complexity? How and why?Write a function to... 阅读全文
posted @ 2015-04-09 10:59 niuer++ 阅读(108) 评论(0) 推荐(0) 编辑
摘要: Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2).You are given a target value t... 阅读全文
posted @ 2015-04-08 19:48 niuer++ 阅读(99) 评论(0) 推荐(0) 编辑
摘要: Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in or... 阅读全文
posted @ 2015-04-08 16:28 niuer++ 阅读(149) 评论(0) 推荐(0) 编辑
摘要: Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in or... 阅读全文
posted @ 2015-04-08 16:19 niuer++ 阅读(145) 评论(0) 推荐(0) 编辑
摘要: 二分查找经常在有序数列中查找某个特定的位置。因此使用二分查找应满足以下两个条件:1:存储在数组中2:有序排列。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。Given a sorted array of integers, find the starting and endi... 阅读全文
posted @ 2015-04-08 15:09 niuer++ 阅读(223) 评论(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-08 10:05 niuer++ 阅读(138) 评论(0) 推荐(0) 编辑
摘要: Given an integern, generate a square matrix filled with elements from 1 ton2in spiral order.For example,Givenn=3,You should return the following matri... 阅读全文
posted @ 2015-04-07 21:28 niuer++ 阅读(115) 评论(0) 推荐(0) 编辑
摘要: Given a matrix ofmxnelements (mrows,ncolumns), return all elements of the matrix in spiral order.For example,Given the following matrix:[ [ 1, 2, 3 ],... 阅读全文
posted @ 2015-04-07 20:36 niuer++ 阅读(228) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8 9 10 下一页