摘要: Given two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space to hold additional elements from B. The number of elements initialized in A and B aremandnrespectively.给定两个有序数组A和B,将B中的元素插入A(假设A有足够大的空间),保持有序性Tip: A和B的大小已知,即合并完成后的数组大小确定。将指针指向A和B的尾 阅读全文
posted @ 2013-10-27 22:57 Apprentice.Z 阅读(132) 评论(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,9,20,#,#,15,7}, 3 / \ 9 20 / \ 15 7return its level order traversal as:[ [3], [9,20], [15,7]]这道题目是二叉树的层次遍历。思路:借助于队列结构(queue),保存尚未访问儿子节点... 阅读全文
posted @ 2013-10-27 22:52 Apprentice.Z 阅读(176) 评论(0) 推荐(0) 编辑
摘要: Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the order ofO(logn).If the target is not found in the array, return[-1, -1].For example,Given[5, 7, 7, 8, 8, 10]and target value 8,return[3, 4].题目要求:查找有序 阅读全文
posted @ 2013-10-27 11:23 Apprentice.Z 阅读(145) 评论(0) 推荐(0) 编辑