随笔分类 -  LeetCode OJ

摘要:leetcode中的题目 直接上代码: 上面是整数转罗马数字的,第一种方法是把所有可能的字符表示出来,然后1-3999的数字是由其相加组成的,依次从最大的先加上去,懂得原理会比较好理解; 第二中是将每一位的可能表示出来,直接算出每一位再替换上去,也比较简单。 下面是罗马数字转整数: 前面的数字比后面 阅读全文
posted @ 2016-10-18 22:49 george_cw 阅读(1026) 评论(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 @ 2015-05-08 23:38 george_cw 阅读(184) 评论(0) 推荐(0)
摘要:Reverse a singly linked list. 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ... 阅读全文
posted @ 2015-05-07 15:10 george_cw 阅读(349) 评论(0) 推荐(0)
摘要:Given an absolute path for a file (Unix-style), simplify it.For example,path="/home/", =>"/home"path="/a/./b/../../c/", =>"/c"click to show corner cas... 阅读全文
posted @ 2014-10-29 20:52 george_cw 阅读(182) 评论(0) 推荐(0)
摘要:Given a linked list, reverse the nodes of a linked listkat a time and return its modified list.If the number of nodes is not a multiple ofkthen left-o... 阅读全文
posted @ 2014-10-26 14:51 george_cw 阅读(161) 评论(0) 推荐(0)
摘要:Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the below binary tree, 1 ... 阅读全文
posted @ 2014-10-26 13:09 george_cw 阅读(150) 评论(0) 推荐(0)
摘要:Reverse Words in a StringGiven an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the". 1 cl... 阅读全文
posted @ 2014-10-19 01:42 george_cw 阅读(210) 评论(0) 推荐(0)