摘要: 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].Note:Try to come... 阅读全文
posted @ 2015-07-19 13:13 小金乌会发光-Z&M 阅读(224) 评论(0) 推荐(0)
摘要: Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as00000010100101000001111010011100), return ... 阅读全文
posted @ 2015-07-19 11:05 小金乌会发光-Z&M 阅读(213) 评论(0) 推荐(0)
摘要: Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as theHamming weight).For example, the 32-bit in... 阅读全文
posted @ 2015-07-19 10:29 小金乌会发光-Z&M 阅读(154) 评论(0) 推荐(0)
摘要: Remove all elements from a linked list of integers that have valueval.ExampleGiven:1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6,val= 6Return:1 --> 2 --> 3 --... 阅读全文
posted @ 2015-07-18 22:04 小金乌会发光-Z&M 阅读(183) 评论(0) 推荐(0)
摘要: 一、Rank ScoresWrite a SQL query to rank scores. If there is a tie between two scores, both should have the same ranking. Note that after a tie, the nex... 阅读全文
posted @ 2015-07-17 19:58 小金乌会发光-Z&M 阅读(197) 评论(0) 推荐(0)
摘要: Given a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space?分析:题意为判断单链表是否为回文的。思路:首先想到的是 遍历一次单链表,... 阅读全文
posted @ 2015-07-17 17:13 小金乌会发光-Z&M 阅读(187) 评论(0) 推荐(0)
摘要: Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to thedefinition of LCA on Wikipedia: ... 阅读全文
posted @ 2015-07-17 10:55 小金乌会发光-Z&M 阅读(197) 评论(0) 推荐(0)
摘要: Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is1 -> 2 -> 3 -> ... 阅读全文
posted @ 2015-07-16 22:28 小金乌会发光-Z&M 阅读(210) 评论(0) 推荐(0)
摘要: You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping yo... 阅读全文
posted @ 2015-07-16 13:36 小金乌会发光-Z&M 阅读(298) 评论(0) 推荐(0)
摘要: 在C&C++中一、inline关键字用来定义一个类的内联函数,引入它的主要原因是用它替代C中表达式形式的宏定义。表达式形式的宏定义一例:#define ExpressionName(Var1,Var2) ((Var1)+(Var2))*((Var1)-(Var2))取代这种形式的原因如下:1. C中... 阅读全文
posted @ 2015-07-15 20:45 小金乌会发光-Z&M 阅读(695) 评论(1) 推荐(1)