随笔分类 -  leetcode

leetcode题解
318. Maximum Product of Word Lengths
摘要:好久没leetcode一下了,以后每天1题,坚持一下~ https://leetcode.com/problems/maximum-product-of-word-lengths/ Total Accepted: 9706 Total Submissions: 24927 Difficulty: M 阅读全文
posted @ 2016-01-30 11:44 星空守望者--jkmiao 阅读(208) 评论(0) 推荐(0) 编辑
Number of Islands
摘要:Given a 2d grid map of'1's (land) and'0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent ... 阅读全文
posted @ 2015-11-10 14:49 星空守望者--jkmiao 阅读(320) 评论(0) 推荐(0) 编辑
Valid Sudoku
摘要:The Sudoku board could be partially filled, where empty cells are filled with the character'.'.A partially filled sudoku which is valid.Note:A valid S... 阅读全文
posted @ 2015-11-05 15:04 星空守望者--jkmiao 阅读(168) 评论(0) 推荐(0) 编辑
House Robber
摘要:You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping yo... 阅读全文
posted @ 2015-10-31 11:44 星空守望者--jkmiao 阅读(137) 评论(0) 推荐(0) 编辑
count and say leetcode @python
摘要:https://leetcode.com/submissions/detail/44515521/ class Solution(object): def count(self,s): res = "" count = 0; cur = "#"... 阅读全文
posted @ 2015-10-30 15:00 星空守望者--jkmiao 阅读(98) 评论(0) 推荐(0) 编辑
Invert Binary Tree
摘要:https://leetcode.com/problems/invert-binary-tree/Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9... 阅读全文
posted @ 2015-10-20 14:57 星空守望者--jkmiao 阅读(135) 评论(0) 推荐(0) 编辑
Word Frequency
摘要:https://leetcode.com/problems/word-frequency/Write a bash script to calculate the frequency of each word in a text filewords.txt.For simplicity sake, ... 阅读全文
posted @ 2015-09-29 11:10 星空守望者--jkmiao 阅读(336) 评论(0) 推荐(0) 编辑
Ugly numbers
摘要:Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include2, 3, 5. For examp... 阅读全文
posted @ 2015-09-15 21:56 星空守望者--jkmiao 阅读(155) 评论(0) 推荐(0) 编辑
Missing Number @leetcode
摘要:Given an array containingndistinct numbers taken from0, 1, 2, ..., n, find the one that is missing from the array.For example,Givennums=[0, 1, 3]retur... 阅读全文
posted @ 2015-09-15 20:58 星空守望者--jkmiao 阅读(183) 评论(0) 推荐(0) 编辑
H-Index II @python
摘要:Follow upforH-Index: What if thecitationsarray is sorted in ascending order? Could you optimize your algorithm?class Solution(object): def hIndex(s... 阅读全文
posted @ 2015-09-15 20:29 星空守望者--jkmiao 阅读(375) 评论(0) 推荐(0) 编辑
Leetcode 之Simplify Path @ python
摘要:Given an absolute path for a file (Unix-style), simplify it.For example,path="/home/", =>"/home"path="/a/./b/../../c/", =>"/c"使用一个栈来解决问题。遇到'..'弹栈,遇到'.... 阅读全文
posted @ 2015-04-21 21:44 星空守望者--jkmiao 阅读(314) 评论(0) 推荐(0) 编辑
Valid Number @python
摘要:Valid NumberValidate if a given string is numeric.Some examples:"0"=>true" 0.1 "=>true"abc"=>false"1 a"=>false"2e10"=>trueNote:It is intended for the ... 阅读全文
posted @ 2015-04-07 21:52 星空守望者--jkmiao 阅读(361) 评论(0) 推荐(0) 编辑