随笔分类 -  数据结构与算法

摘要:Description:Count the number of prime numbers less than a non-negative number,n.传送门:https://leetcode.com/problems/count-primes/尽可能把查找次数缩小,直接用双重for会超时。... 阅读全文
posted @ 2015-08-05 09:54 zetrov 阅读(190) 评论(0) 推荐(0) 编辑
摘要:There are a total ofncourses you have to take, labeled from0ton - 1.Some courses may have prerequisites, for example to take course 0 you have to firs... 阅读全文
posted @ 2015-08-05 09:34 zetrov 阅读(336) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree, return thezigzag level ordertraversal of its nodes' values. (ie, from left to right, then right to left for the next level and al... 阅读全文
posted @ 2015-08-05 09:32 zetrov 阅读(319) 评论(0) 推荐(0) 编辑
摘要: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-08-03 16:06 zetrov 阅读(462) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree, imagine yourself standing on therightside of it, return the values of the nodes you can see ordered from top to bottom.For exampl... 阅读全文
posted @ 2015-08-03 16:02 zetrov 阅读(282) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree, return thebottom-up level ordertraversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For exa... 阅读全文
posted @ 2015-08-03 16:00 zetrov 阅读(273) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree, return thelevel ordertraversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree{3,9,2... 阅读全文
posted @ 2015-08-03 15:56 zetrov 阅读(324) 评论(0) 推荐(0) 编辑
摘要:题目描述:小明手中有很多字符串卡片,每个字符串中都包含有多个连续的空格,而且这些卡片在印刷的过程中将字符串的每个子串都打印反了,现在麻烦你帮小明将这些字符串中的子串修正过来,同时为了使卡片美观,压缩其中的连续空格为1个。输入:输入包含多个测试用例,每个测试用例的第一行是一个正整数 n,1= 2 #... 阅读全文
posted @ 2015-03-27 00:07 zetrov 阅读(169) 评论(0) 推荐(0) 编辑