bfs
文章平均质量分 78
哎-哭泣的鱼
这个作者很懒,什么都没留下…
展开
-
【九度】题目1523:从上往下打印二叉树
题目描述:从上往下打印出二叉树的每个节点,同层节点从左至右打印。输入:输入可能包含多个测试样例,输入以EOF结束。对于每个测试案例,输入的第一行一个整数n(1Ci=’d’表示第i个节点有两子孩子,紧接着是左孩子编号和右孩子编号。Ci=’l’表示第i个节点有一个左孩子,紧接着是左孩子的编号。Ci=’r’表示第i个节点有一个右孩子,紧接着是右孩子的编号。Ci=’z’表示原创 2014-01-10 14:04:52 · 854 阅读 · 0 评论 -
【九度】题目1456:胜利大逃亡
题目描述:Ignatius被魔王抓走了,有一天魔王出差去了,这可是Ignatius逃亡的好机会.魔王住在一个城堡里,城堡是一个A*B*C的立方体,可以被表示成A个B*C的矩阵,刚开始Ignatius被关在(0,0,0)的位置,离开城堡的门在(A-1,B-1,C-1)的位置,现在知道魔王将在T分钟后回到城堡,Ignatius每分钟能从一个坐标走到相邻的六个坐标中的其中一个.现在给你城堡的地图原创 2013-12-06 21:18:09 · 971 阅读 · 0 评论 -
【LeetCode】Number of Islands
Number of Islands Total Accepted: 8945 Total Submissions: 41107 My Submissions Question Solution Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surr原创 2015-06-02 09:28:51 · 816 阅读 · 0 评论 -
【LeetCode】Palindrome Partitioning I&II
原文来自http://blog.csdn.net/yutianzuijin/article/details/16850031leetcodeDP深搜回文串目录(?)[+]Palindrome PartitioningPalindrome Partitioning II深搜DP1 Palindrome Partitioning问题来源:Pa转载 2014-01-13 17:53:45 · 779 阅读 · 0 评论 -
【LeetCode】Surrounded Regions
Surrounded Regions Total Accepted: 4485 Total Submissions: 31870 My SubmissionsGiven a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'.A region is captured by flipping all原创 2014-02-24 13:47:48 · 1083 阅读 · 0 评论 -
【LeetCode】Binary Tree Zigzag Level Order Traversal
Binary Tree Zigzag Level Order Traversal Total Accepted: 3689 Total Submissions: 14306 My SubmissionsGiven a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left原创 2014-01-14 17:36:36 · 900 阅读 · 0 评论 -
【LeetCode】N-Queens && 【九度】题目1140:八皇后
N-Queens Total Accepted: 3171 Total Submissions: 12620 My SubmissionsThe n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.Given原创 2014-01-15 16:55:31 · 1436 阅读 · 0 评论 -
【LeetCode】Word Search
Word Search Total Accepted: 7113 Total Submissions: 36905 My SubmissionsGiven a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially原创 2014-04-15 19:47:50 · 1905 阅读 · 0 评论 -
【LeetCode】Binary Tree Level Order Traversal
Binary Tree Level Order Traversal Total Accepted: 5091 Total Submissions: 16977 My SubmissionsGiven a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, lev原创 2014-01-10 13:26:34 · 958 阅读 · 0 评论 -
【LeetCode】Path Sum
Path Sum Total Accepted: 5082 Total Submissions: 17224 My SubmissionsGiven a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path eq原创 2014-01-08 14:10:19 · 1054 阅读 · 0 评论 -
【LeetCode】Word Ladder
Word Ladder Total Accepted: 9317 Total Submissions: 53652 My SubmissionsGiven two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, su原创 2014-05-05 13:28:44 · 779 阅读 · 0 评论 -
【LeetCode】Path Sum II
Path Sum II Total Accepted: 4441 Total Submissions: 16502 My SubmissionsGiven a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given th原创 2014-01-08 15:42:41 · 1364 阅读 · 0 评论 -
【LeetCode】Binary Tree Level Order Traversal II
Binary Tree Level Order Traversal II Total Accepted: 4229 Total Submissions: 13624 My SubmissionsGiven a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left原创 2014-01-12 22:27:41 · 896 阅读 · 0 评论 -
【LeetCode】Word Ladder
Word Ladder Total Accepted: 3388 Total Submissions: 21998 My SubmissionsGiven two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such原创 2013-12-31 14:21:16 · 1082 阅读 · 0 评论 -
【九度】题目1335:闯迷宫(40分)
题目描述:sun所在学校每年都要举行电脑节,今年电脑节有一个新的趣味比赛项目叫做闯迷宫。sun的室友在帮电脑节设计迷宫,所以室友就请sun帮忙计算下走出迷宫的最少步数。知道了最少步数就可以辅助控制比赛难度以及去掉一些没有路径到达终点的map。比赛规则是:从原点(0,0)开始走到终点(n-1,n-1),只能上下左右4个方向走,只能在给定的矩阵里走。输入:输入有原创 2013-12-06 21:33:36 · 2448 阅读 · 0 评论 -
【九度】题目1460:Oil Deposit
题目描述:The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangular region of land at a time, and creates a grid that d原创 2013-12-20 16:33:33 · 1215 阅读 · 0 评论 -
【九度】题目1482:玛雅人的密码
题目描述:玛雅人有一种密码,如果字符串中出现连续的2012四个数字就能解开密码。给一个长度为N的字符串,(2=输入:输入包含多组测试数据,每组测试数据由两行组成。第一行为一个整数N,代表字符串的长度(2第二行为一个仅由0、1、2组成的,长度为N的字符串。输出:对于每组测试数据,若可以解出密码,输出最少的移位次数;否则输出-1。样例原创 2013-12-19 15:09:53 · 2460 阅读 · 0 评论 -
【LeetCode】Palindrome Partitioning
Palindrome Partitioning Total Accepted: 4268 Total Submissions: 17532 My SubmissionsGiven a string s, partition s such that every substring of the partition is a palindrome.Return all possible pal原创 2014-01-14 14:21:50 · 1954 阅读 · 5 评论 -
【九度】题目1539:师弟
题目描述:开学了,GrassLand的新师弟也来了,于是GrassLand打算去路口接他,以表兄长之谊。已知:共有n个路口,n个路口间存在着m条道路,每条道路连接两个路口,道路有其各自的长度。GrassLand和他的实验室在1号路口,而他的师弟在n号路口。师弟沿着最短路径走向实验室,若有多于一条的最短路径,他会任意选择一条。GrassLand不希望走的太远而浪费科研的时原创 2013-12-26 13:57:53 · 869 阅读 · 0 评论