Fork me on GitHub

09 2015 档案

摘要:题目:Find the total area covered by tworectilinearrectangles in a2Dplane.Each rectangle is defined by its bottom left corner and top right corner as sho... 阅读全文
posted @ 2015-09-12 17:30 __Neo 阅读(205) 评论(0) 推荐(0)
摘要:题目:Given an integern, return the number of trailing zeroes inn!.Note:Your solution should be in logarithmic time complexity.提示:此题要求出n阶乘的结尾零的个数。因为当且仅当阶... 阅读全文
posted @ 2015-09-12 15:07 __Neo 阅读(92) 评论(0) 推荐(0)
摘要:题目:Reverse a singly linked list.提示:此题不难,可以用迭代或者递归两种方法求解。记得要把原来的链表头的next置为NULL;代码:迭代:/** * Definition for singly-linked list. * struct ListNode { * ... 阅读全文
posted @ 2015-09-10 16:45 __Neo 阅读(116) 评论(0) 推荐(0)
摘要:题目:Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: ... 阅读全文
posted @ 2015-09-10 11:55 __Neo 阅读(174) 评论(0) 推荐(0)
摘要:题目:Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as00000010100101000001111010011100), retu... 阅读全文
posted @ 2015-09-10 11:13 __Neo 阅读(125) 评论(0) 推荐(0)
摘要:题目:Compare two version numbersversion1andversion2.Ifversion1>version2return 1, ifversion1 -1) { v1 = atoi(version1.substr(0, pos1).c_st... 阅读全文
posted @ 2015-09-09 19:53 __Neo 阅读(168) 评论(0) 推荐(0)
摘要:题目:Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Remo... 阅读全文
posted @ 2015-09-09 13:50 __Neo 阅读(321) 评论(0) 推荐(0)
摘要:题目:Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum... 阅读全文
posted @ 2015-09-08 15:29 __Neo 阅读(145) 评论(0) 推荐(0)
摘要:题目:Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest... 阅读全文
posted @ 2015-09-08 15:09 __Neo 阅读(243) 评论(0) 推荐(0)
摘要:题目:Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the de... 阅读全文
posted @ 2015-09-08 14:43 __Neo 阅读(140) 评论(0) 推荐(0)
摘要:题目:Given a binary tree, return thebottom-up level ordertraversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For ... 阅读全文
posted @ 2015-09-07 20:07 __Neo 阅读(147) 评论(0) 推荐(0)
摘要:题目:Given a binary tree, return thelevel ordertraversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree{3,... 阅读全文
posted @ 2015-09-06 21:03 __Neo 阅读(332) 评论(0) 推荐(0)
摘要:题目:Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / ... 阅读全文
posted @ 2015-09-06 19:28 __Neo 阅读(151) 评论(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... 阅读全文
posted @ 2015-09-05 14:39 __Neo 阅读(152) 评论(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... 阅读全文
posted @ 2015-09-02 15:24 __Neo 阅读(159) 评论(0) 推荐(0)
摘要:题目:Given an indexk, return thekthrow of the Pascal's triangle.For example, givenk= 3,Return[1,3,3,1].Note:Could you optimize your algorithm to use onl... 阅读全文
posted @ 2015-09-02 14:45 __Neo 阅读(144) 评论(0) 推荐(0)
摘要:题目:GivennumRows, generate the firstnumRowsof Pascal's triangle.For example, givennumRows= 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4... 阅读全文
posted @ 2015-09-02 09:31 __Neo 阅读(157) 评论(0) 推荐(0)
摘要:题目:Given an integer, write a function to determine if it is a power of two.提示:此题判断输入的数是否是2的次方。如果一个数是2的次方,那么它的二进制数只有一个1,其他都是0。根据这一定理,我们可以用如下方法解决这一问题:第一... 阅读全文
posted @ 2015-09-01 16:03 __Neo 阅读(147) 评论(0) 推荐(0)
摘要:题目:Implement the following operations of a stack using queues.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.to... 阅读全文
posted @ 2015-09-01 14:53 __Neo 阅读(343) 评论(0) 推荐(0)
摘要:题目:Implement the following operations of a queue using stacks.push(x) -- Push element x to the back of queue.pop() -- Removes the element from in fron... 阅读全文
posted @ 2015-09-01 14:30 __Neo 阅读(127) 评论(0) 推荐(0)