上一页 1 ··· 44 45 46 47 48 49 50 51 52 ··· 80 下一页
摘要: 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-03-20 16:27 匡子语 阅读(181) 评论(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-03-18 16:07 匡子语 阅读(205) 评论(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-03-17 21:57 匡子语 阅读(194) 评论(0) 推荐(0)
摘要: Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as00000010100101000001111010011100), return ... 阅读全文
posted @ 2015-03-17 17:33 匡子语 阅读(175) 评论(0) 推荐(0)
摘要: 做太多遍了,秒杀。class Solution {public: int hammingWeight(uint32_t n) { int num = 0; for(;n; n &=(n-1), num++); return num; }}; 阅读全文
posted @ 2015-03-17 16:59 匡子语 阅读(182) 评论(0) 推荐(0)
摘要: Given amxnmatrix, if an element is 0, set its entire row and column to 0. Do it in place.思路:不能用额外空间,就用矩阵的第一行和第一列来标记这一行或这一列是否需要置0. 用两个bool量记录第一行和第一列是否需... 阅读全文
posted @ 2015-03-17 16:53 匡子语 阅读(231) 评论(0) 推荐(0)
摘要: Given a singly linked listL:L0→L1→…→Ln-1→Ln,reorder it to:L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For exam... 阅读全文
posted @ 2015-03-16 21:59 匡子语 阅读(230) 评论(0) 推荐(0)
摘要: Reverse a linked list from positionmton. Do it in-place and in one-pass.For example:Given1->2->3->4->5->NULL,m= 2 andn= 4,return1->4->3->2->5->NULL.思路... 阅读全文
posted @ 2015-03-12 21:36 匡子语 阅读(199) 评论(0) 推荐(0)
摘要: Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should preserve the origi... 阅读全文
posted @ 2015-03-12 20:33 匡子语 阅读(166) 评论(0) 推荐(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.思路:使用伪头部c... 阅读全文
posted @ 2015-03-12 20:21 匡子语 阅读(142) 评论(0) 推荐(0)
上一页 1 ··· 44 45 46 47 48 49 50 51 52 ··· 80 下一页