摘要:Given a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list as2->1->4->3.Your algor... 阅读全文
posted @ 2015-03-17 22:46 desperadox 阅读 (54) 评论 (0) 编辑
摘要:Given an array withnobjects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, wh... 阅读全文
posted @ 2015-03-17 22:44 desperadox 阅读 (46) 评论 (0) 编辑
摘要:A robot is located at the top-left corner of amxngrid (marked 'Start' in the diagram below).The robot can only move either down or right at any point ... 阅读全文
posted @ 2015-03-17 22:41 desperadox 阅读 (83) 评论 (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).Find the minimum element.You m... 阅读全文
posted @ 2015-03-17 22:40 desperadox 阅读 (20) 评论 (0) 编辑
摘要:Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.一直没想出原址排序... 阅读全文
posted @ 2015-03-15 23:24 desperadox 阅读 (32) 评论 (0) 编辑
摘要:Given an array where elements are sorted in ascending order, convert it to a height balanced BST.分治是比较好而且容易想到的思路。 1 class Solution { 2 public: 3 T... 阅读全文
posted @ 2015-03-15 23:07 desperadox 阅读 (32) 评论 (0) 编辑
摘要:A robot is located at the top-left corner of amxngrid (marked 'Start' in the diagram below).The robot can only move either down or right at any point ... 阅读全文
posted @ 2015-03-15 22:44 desperadox 阅读 (130) 评论 (0) 编辑
摘要:You are climbing a stair case. It takesnsteps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb... 阅读全文
posted @ 2015-03-15 22:10 desperadox 阅读 (33) 评论 (0) 编辑
摘要:Given a sorted linked list, delete all duplicates such that each element appear onlyonce.简单题,注意逻辑顺序就好了。 1 class Solution { 2 public: 3 ListNode *d... 阅读全文
posted @ 2015-03-15 21:46 desperadox 阅读 (34) 评论 (0) 编辑
摘要:Given an array of sizen, find the majority element. The majority element is the element that appears more than⌊ n/2 ⌋times.You may assume that the arr... 阅读全文
posted @ 2015-03-15 20:48 desperadox 阅读 (54) 评论 (0) 编辑