摘要:
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 onlyO(k) extra space?class Solution {public: vector getRow(int rowIndex) { // IMPORTANT: Please reset any member data you declared, as // the same ... 阅读全文
posted @ 2013-11-12 19:43
xchangcheng
阅读(143)
评论(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.For example:Given the below binary tree andsum = 22, 5 / \ 4 8 / / \ 11 13 4 / \ ... 阅读全文
posted @ 2013-11-12 13:26
xchangcheng
阅读(229)
评论(0)
推荐(0)
摘要:
Write an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row are sorted from left to right.The first integer of each row is greater than the last integer of the previous row.For example,Consider the following matrix:[ [1, 3, ... 阅读全文
posted @ 2013-11-12 12:23
xchangcheng
阅读(156)
评论(0)
推荐(0)
摘要:
Given a number represented as an array of digits, plus one to the number.class Solution {public: vector plusOne(vector &digits) { // IMPORTANT: Please reset any member data you declared, as // the same Solution instance will be reused for each test case. int a = 1; vec... 阅读全文
posted @ 2013-11-12 12:13
xchangcheng
阅读(661)
评论(0)
推荐(0)

浙公网安备 33010602011771号