欢迎来到PJCK的博客

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

摘要:【问题描述】 kotori在一个n*m迷宫里,迷宫的最外层被岩浆淹没,无法涉足,迷宫内有k个出口。kotori只能上下左右四个方向移动。她想知道有多少出口是她能到达的,最近的出口离她有多远? 【输入】 第一行为两个整数n和m,代表迷宫的行和列数 (1≤n,m≤30) 后面紧跟着n行长度为m的字符串来 阅读全文
posted @ 2019-05-17 22:40 PJCK 阅读(375) 评论(0) 推荐(0)
摘要:There are N students in a class. Some of them are friends, while some are not. Their friendship is transitive in nature. For example, if A is a direct 阅读全文
posted @ 2019-05-17 16:27 PJCK 阅读(246) 评论(0) 推荐(0)
摘要:There are N rooms and you start in room 0. Each room has a distinct number in 0, 1, 2, ..., N-1, and each room may have some keys to access the next r 阅读全文
posted @ 2019-05-17 09:56 PJCK 阅读(150) 评论(0) 推荐(0)
摘要:An image is represented by a 2-D array of integers, each integer representing the pixel value of the image (from 0 to 65535). Given a coordinate (sr, 阅读全文
posted @ 2019-05-16 20:58 PJCK 阅读(129) 评论(0) 推荐(0)
摘要:Given a 2D array A, each cell is 0 (representing sea) or 1 (representing land) A move consists of walking from one land square 4-directionally to anot 阅读全文
posted @ 2019-05-15 21:19 PJCK 阅读(133) 评论(0) 推荐(0)
摘要:迷宫问题 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 41913 Accepted: 23240 Description 定义一个二维数组: int maze[5][5] = { 0, 1, 0, 0, 0, 0, 1, 0, 阅读全文
posted @ 2019-05-15 13:08 PJCK 阅读(190) 评论(0) 推荐(0)
摘要:Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) Yo 阅读全文
posted @ 2019-05-15 08:59 PJCK 阅读(152) 评论(0) 推荐(0)
摘要:Given an array A of integers, we must modify the array in the following way: we choose an i and replace A[i] with -A[i], and we repeat this process K  阅读全文
posted @ 2019-05-06 22:08 PJCK 阅读(105) 评论(0) 推荐(0)
摘要:Given two words (beginWord and endWord), and a dictionary's word list, find the length of shortest transformation sequence from beginWord to endWord, 阅读全文
posted @ 2019-05-05 14:30 PJCK 阅读(129) 评论(0) 推荐(0)
摘要:You have a lock in front of you with 4 circular wheels. Each wheel has 10 slots: '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'. The wheels can rota 阅读全文
posted @ 2019-05-01 10:29 PJCK 阅读(175) 评论(0) 推荐(0)
摘要:Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and 阅读全文
posted @ 2019-04-29 20:32 PJCK 阅读(96) 评论(0) 推荐(0)
摘要:In a binary tree, the root node is at depth 0, and children of each depth knode are at depth k+1. Two nodes of a binary tree are cousins if they have 阅读全文
posted @ 2019-04-28 22:42 PJCK 阅读(180) 评论(0) 推荐(0)
摘要:Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root). For 阅读全文
posted @ 2019-04-28 20:17 PJCK 阅读(123) 评论(0) 推荐(0)
摘要:Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n. Example 1: Example 2: 阅读全文
posted @ 2019-04-25 19:37 PJCK 阅读(173) 评论(0) 推荐(0)
摘要:Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree [1,2,2,3,4,4,3] is symmet 阅读全文
posted @ 2019-04-19 20:28 PJCK 阅读(107) 评论(0) 推荐(0)
摘要:Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. Example 阅读全文
posted @ 2019-04-17 08:07 PJCK 阅读(129) 评论(0) 推荐(0)
摘要:Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example:Given binary tree [3 阅读全文
posted @ 2019-04-17 08:02 PJCK 阅读(112) 评论(0) 推荐(0)
摘要:You need to find the largest value in each row of a binary tree. Example: 阅读全文
posted @ 2019-04-16 12:48 PJCK 阅读(104) 评论(0) 推荐(0)
摘要:Given a binary tree, find the leftmost value in the last row of the tree. Example 1: Example 2: Note: You may assume the tree (i.e., the given root no 阅读全文
posted @ 2019-04-16 12:28 PJCK 阅读(113) 评论(0) 推荐(0)
摘要:Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest l 阅读全文
posted @ 2019-04-16 09:24 PJCK 阅读(129) 评论(0) 推荐(0)