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...
阅读全文
摘要:题目:Given an integern, return the number of trailing zeroes inn!.Note:Your solution should be in logarithmic time complexity.提示:此题要求出n阶乘的结尾零的个数。因为当且仅当阶...
阅读全文
摘要:题目:Reverse a singly linked list.提示:此题不难,可以用迭代或者递归两种方法求解。记得要把原来的链表头的next置为NULL;代码:迭代:/** * Definition for singly-linked list. * struct ListNode { * ...
阅读全文
摘要:题目: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: ...
阅读全文
摘要:题目:Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as00000010100101000001111010011100), retu...
阅读全文
摘要:题目:Compare two version numbersversion1andversion2.Ifversion1>version2return 1, ifversion1 -1) { v1 = atoi(version1.substr(0, pos1).c_st...
阅读全文
摘要:题目: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...
阅读全文
摘要:题目: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...
阅读全文
摘要:题目: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...
阅读全文
摘要:题目: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...
阅读全文
摘要:题目: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 ...
阅读全文
摘要:题目: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,...
阅读全文
摘要:题目: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 / ...
阅读全文
摘要:题目: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...
阅读全文
摘要:题目: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...
阅读全文
摘要:题目: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...
阅读全文
摘要:题目: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...
阅读全文
摘要:题目:Given an integer, write a function to determine if it is a power of two.提示:此题判断输入的数是否是2的次方。如果一个数是2的次方,那么它的二进制数只有一个1,其他都是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...
阅读全文
摘要:题目: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...
阅读全文


浙公网安备 33010602011771号