
数据结构与算法
文章平均质量分 89
fgao2
这个作者很懒,什么都没留下…
展开
-
leetcode 题解:Word Ladder 2(单词接龙 2)
Given two words (beginWord and endWord), and a dictionary’s word list, find all shortest transformation sequence(s) from beginWord to endWord, such that:(给定两个单词(beginWord 和 endWord)和一个字典 wordList,找出所有从 beginWord 到 endWord 的最短转换序列。转换需遵循如下规则Only one letter原创 2021-01-18 00:07:04 · 320 阅读 · 0 评论 -
leetcode(力扣题解) 15. 3Sum(三数之和)
题目:Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.(给定一个含有n个数的数组,找出数组中三个元素a,b,c, 使得a+b+c=0, 找出所以互不重复的满足三数之和为0的数组)Notice that the solution set原创 2020-12-25 20:02:54 · 274 阅读 · 1 评论 -
leetcode (力扣)题解 206. Reverse Linked List (链表反转)
leetcode (力扣)题解 206. Reverse Linked List (链表反转)题目:Reverse a singly linked list.(反转单链表)Example:Input: 1->2->3->4->5->NULLOutput: 5->4->3->2->1->NULLFollow up:A linked list can be reversed either iteratively or recursivel原创 2020-12-25 17:03:43 · 224 阅读 · 0 评论 -
通过归并排序算法(mergesort)理解递归在程序中的运行过程
递归的重要性不言而喻,它是很多算法实现的基础,比如含有分治思想的算法(归并排序,二分查找),有关遍历二叉树的算法,或者求解数学递推式的算法(斐波那契数列,n的阶乘),回溯法,动态规划等等, 一提到递归总有点发蒙,理论上比较好理解,但是一遇到复杂一点的递归算法,在大脑中很难想象递归在计算机中是怎么实现的。跟着一步步debug才终于搞明白,所以在这里先把过程给记录下来。 归并排序算法...原创 2020-03-27 17:38:45 · 1458 阅读 · 0 评论 -
leetcode题解:784. Letter Case Permutation(字母大小写排列)
Given a string S, we can transform every letter individually to be lowercase or uppercase to create another string. Return a list of all possible strings we could create.(对于给定的字符串S,我们可以将其中的每一个字母转成大写或...原创 2020-03-20 21:13:32 · 276 阅读 · 0 评论