dfs 栈溢出,bfs超时,用dfs非递归就不溢出了,前后写了1一个星期class node { int i; int j; public node(int i1,int j1) { i=i1; j=j1; } } public class Solution { public void solve(char[][] board) { int len1=board.length; if(len1<=0)return; int len2=board[0].length; if(len1<=2||l…
[LeetCode]Island Perimeter 解题报告 [LeetCode] https://leetcode.com/problems/island-perimeter/ Total Accepted: 16143 Total Submissions: 28552 Difficulty: Easy Question You are given a map in form of a two-dimensional integer grid where 1 represents land…
Algorithm [leetcode]893. Groups of Special-Equivalent Strings https://leetcode.com/problems/groups-of-special-equivalent-strings/ 1)problem You are given an array A of strings. Two strings S and T are special-equivalent if after any number of moves,…
Algorithm [leetcode]657. Robot Return to Origin https://leetcode.com/problems/robot-return-to-origin/ 1)problem There is a robot starting at position (0, 0), the origin, on a 2D plane. Given a sequence of its moves, judge if this robot ends up at (0,…
Algorithm [leetcode]557. Reverse Words in a String III https://leetcode.com/problems/reverse-words-in-a-string-iii/ 1)problem Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace…
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 BFS 日期 题目地址:https://leetcode-cn.com/problems/ji-qi-ren-de-yun-dong-fan-wei-lcof/ 题目描述 地上有一个m行n列的方格,从坐标 [0,0] 到坐标 [m-1,n-1] .一个机器人从坐标 [0, 0] 的格子开始移动,它每次可以向左.右.上.下移动一格(不能移动到方格外),也…
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 这个题想考察什么? 剩下的任务就是套模板! 日期 题目地址:https://leetcode-cn.com/problems/as-far-from-land-as-possible/ 题目描述 你现在手里有一份大小为 N x N 的 网格 grid,上面的每个 单元格 都用 0 和 1 标记好了.其中 0 代表海洋,1 代表陆地,请你找出一个海洋单元…
[LeetCode]01 Matrix 解题报告 标签(空格分隔): LeetCode 题目地址:https://leetcode.com/problems/01-matrix/#/description 题目描述: Given a matrix consists of 0 and 1, find the distance of the nearest 0 for each cell. The distance between two adjacent cells is 1. Example:…
[LeetCode]Longest Word in Dictionary through Deleting 解题报告 标签(空格分隔): LeetCode 题目地址:https://leetcode.com/problems/longest-word-in-dictionary-through-deleting/#/description 题目描述: Given a string and a string dictionary, find the longest string in the di…
[LeetCode]Largest Number 解题报告 标签(空格分隔): LeetCode 题目地址:https://leetcode.com/problems/largest-number/#/description 题目描述: Given a list of non negative integers, arrange them such that they form the largest number. For example, given [3, 30, 34, 5, 9], t…