上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 17 下一页
摘要: Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.OJ's undirected graph serialization:Nodes are labeled uniquely.We use # as a separator for each node, and , as a separator for node label and each neighbor of the node.As an example, consider the seria 阅读全文
posted @ 2013-10-03 00:58 懒猫欣 阅读(260) 评论(0) 推荐(0)
摘要: 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)
摘要: 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 = "H 阅读全文
posted @ 2013-09-24 23:36 懒猫欣 阅读(173) 评论(0) 推荐(0)
摘要: Given a list, rotate the list to the right by k places, where k is non-negative.For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3->NULL.记住是向右移。。/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) 阅读全文
posted @ 2013-09-24 23:22 懒猫欣 阅读(118) 评论(0) 推荐(0)
摘要: Given a set of distinct integers, S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not contain duplicate subsets.For example,If S = [1,2,3], a solution is:[ [3], [1], [2], [1,2,3], [1,3], [2,3], [1,2], []]注意空集class Solution {publi... 阅读全文
posted @ 2013-09-24 23:00 懒猫欣 阅读(181) 评论(0) 推荐(0)
摘要: Givennnon-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.For example,Given[0,1,0,2,1,0,1,3,2,1,2,1], return6.用一个栈辅助,小于等于栈顶的话压入,大于栈顶就把所有小于当前值的元素出栈,计算面积面积也用一个栈,每次把新的面积覆盖范围内的所有的面积出栈,剩下到最后的就是相互独立的了将这些面积加起来,并且减去下面的 阅读全文
posted @ 2013-09-24 22:39 懒猫欣 阅读(186) 评论(0) 推荐(0)
摘要: 转自 http://www.cnblogs.com/goodhacker/archive/2011/07/20/2111996.htmlC风格的强制类型转换(Type Cast)很简单,不管什么类型的转换统统是:TYPE b = (TYPE)a。C++风格的类型转换提供了4种类型转换操作符来应对不同场合的应用。const_cast,字面上理解就是去const属性。static_cast,命名上理解是静态类型转换。如int转换成char。dynamic_cast,命名上理解是动态类型转换。如子类和父类之间的多态类型转换。reinterpret_cast,仅仅重新解释类型,但没有进行二进制的转换。 阅读全文
posted @ 2013-09-24 17:23 懒猫欣 阅读(185) 评论(0) 推荐(0)
上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 17 下一页