随笔分类 -  LeetCode OJ

摘要:Given an array withnobjects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, wh... 阅读全文
posted @ 2014-07-20 16:30 Marrybe 阅读(153) 评论(0) 推荐(0)
摘要:Givennnon-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histog... 阅读全文
posted @ 2014-07-20 12:17 Marrybe 阅读(148) 评论(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 "adjace... 阅读全文
posted @ 2014-07-18 12:16 Marrybe 阅读(243) 评论(0) 推荐(0)
摘要:需要仔细回顾的题目:1.Interleaving String 交叉存取字符串2.Decode Ways 字符串解码3.Subsets Subsets II 求一个集合的幂集 阅读全文
posted @ 2014-07-16 19:51 Marrybe 阅读(122) 评论(0) 推荐(0)
摘要:Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.下面是百度得到的关于罗马数的解释:我的代码: 1 class Solution { 2 ... 阅读全文
posted @ 2014-07-15 21:12 Marrybe 阅读(152) 评论(0) 推荐(0)
摘要:A message containing letters fromA-Zis being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message conta... 阅读全文
posted @ 2014-07-15 19:19 Marrybe 阅读(159) 评论(0) 推荐(0)
摘要:You are climbing a stair case. It takesnsteps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb... 阅读全文
posted @ 2014-06-20 12:27 Marrybe 阅读(140) 评论(1) 推荐(0)
摘要:Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ ... 阅读全文
posted @ 2014-06-16 22:50 Marrybe 阅读(256) 评论(0) 推荐(0)
摘要:Given a stringSand a stringT, count the number of distinct subsequences ofTinS.A subsequence of a string is a new string which is formed from the orig... 阅读全文
posted @ 2014-06-14 18:07 Marrybe 阅读(141) 评论(0) 推荐(0)
摘要:Say you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to complete at most one transaction (ie... 阅读全文
posted @ 2014-06-12 21:53 Marrybe 阅读(139) 评论(0) 推荐(0)
摘要:问题描述:There areNgas stations along a circular route, where the amount of gas at stationiisgas[i].You have a car with an unlimited gas tank and it costs... 阅读全文
posted @ 2014-06-10 19:18 Marrybe 阅读(199) 评论(0) 推荐(0)
摘要:1 class Solution { 2 public: 3 int singleNumber(int A[], int n) { 4 int bits = sizeof(int)*8; 5 int result=0; 6 for(int i... 阅读全文
posted @ 2014-06-10 11:48 Marrybe 阅读(216) 评论(0) 推荐(0)
摘要:1 class Solution { 2 public: 3 int singleNumber(int A[], int n) { 4 int i,j; 5 for(i=0; i<n; i++) 6 { 7 for(j... 阅读全文
posted @ 2014-06-09 23:12 Marrybe 阅读(298) 评论(0) 推荐(0)
摘要:There areNchildren standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requi... 阅读全文
posted @ 2014-06-09 21:49 Marrybe 阅读(185) 评论(0) 推荐(0)
摘要:For example,Given{1,2,3,4}, reorder it to{1,4,2,3}. 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * Li... 阅读全文
posted @ 2014-06-09 15:25 Marrybe 阅读(748) 评论(0) 推荐(0)
摘要:1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x), ne... 阅读全文
posted @ 2014-06-09 15:20 Marrybe 阅读(167) 评论(0) 推荐(0)
摘要://定义二维平面上的点struct Point{ int x; int y; Point(int a=0, int b=0):x(a),y(b){}};bool operator==(const Point& left, const Point& right){ return... 阅读全文
posted @ 2014-06-07 23:39 Marrybe 阅读(1420) 评论(0) 推荐(0)