摘要: Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a container, such that the container contains the most water 阅读全文
posted @ 2013-10-02 18:10 懒猫欣 阅读(144) 评论(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-10-02 17:21 懒猫欣 阅读(148) 评论(0) 推荐(0)
摘要: Given an array of integers, all elements are repeated twice except for one. Find that single one.Could you implement it without using extra memory?牢记异或,愿异或母亲忽悠着你class Solution {public: int singleNumber(int A[], int n) { // Note: The Solution object is instantiated only once and is reused b... 阅读全文
posted @ 2013-10-02 16:35 懒猫欣 阅读(159) 评论(0) 推荐(0)
摘要: Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determine if you are able to reach the last index. For example:A = [2,3,1,1,4], return true.A = [3,2,1,0,4], return fal 阅读全文
posted @ 2013-10-02 10:29 懒猫欣 阅读(142) 评论(0) 推荐(0)