摘要: 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 of O(log n).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-11-19 21:21 七年之后 阅读(182) 评论(0) 推荐(0) 编辑
摘要: Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically neighboring. The same letter cell may not be used more than once.For example, Given board =[ 阅读全文
posted @ 2013-11-19 19:54 七年之后 阅读(166) 评论(0) 推荐(0) 编辑
摘要: Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, return 0.Note: A word is defined as a character sequence consists of non-space characters only.For example, Given s = "He 阅读全文
posted @ 2013-11-19 15:05 七年之后 阅读(215) 评论(0) 推荐(0) 编辑
摘要: Implement pow(x, n).思考:一开始想的太复杂了,跟这一题联系起来了(链接)。后来看到返回值是double型,所以此题就没有那么复杂了。毕竟面试题不会要求写一大堆代码的,最重要的还是考察算法思想:快速幂取模,当然这里不用取模。class Solution {public: double pow(double x, int n) { // IMPORTANT: Please reset any member data you declared, as // the same Solution instance will be reused for... 阅读全文
posted @ 2013-11-19 14:15 七年之后 阅读(225) 评论(0) 推荐(0) 编辑