dfs
文章平均质量分 58
小伤口
这个作者很懒,什么都没留下…
展开
-
字符串排列问题
输入一个字符串,打印出该字符串中字符的所有排列。你可以以任意顺序返回这个字符串数组,但里面不能有重复元素。示例:输入:s = “abc”输出:[“abc”,“acb”,“bac”,“bca”,“cab”,“cba”]回溯法对于一个长度为 n 的字符串(假设字符互不重复),其排列方案数共有: n×(n−1)×(n−2)…×2×1根据字符串排列的特点,考虑深度优先搜索所有排列方案。即通过字符交换,先固定第 1 位字符( n 种情原创 2021-04-15 17:49:29 · 111 阅读 · 0 评论 -
回溯+递归+dfs之求指定岛屿面积与数量问题
Given an m x n 2d grid map of '1’s (land) and '0’s (water), return the number of islands which the sum of 1‘s on the island equal S (S>0).An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically.You may as原创 2021-04-15 16:05:38 · 289 阅读 · 0 评论