关于栈、队列和递归的几个必知必会的代码实现
栈
用数组实现一个顺序栈
用链表实现一个链式栈
编程模拟实现一个浏览器的前进、后退功能
队列
用数组实现一个顺序队列
用链表实现一个链式队列
实现一个循环队列
递归
编程实现斐波那契数列求值f(n)=f(n-1)+f(n-2)
编程实现求阶乘n!
编程实现一组数据集合的全排列
对应的LeetCode练习题(@Smallfly 整理)
栈
Valid Parentheses(有效的括号)
英文版:https://leetcode.com/problems/valid-parentheses/
中文版:https://leetcode-cn.com/problems/valid-parentheses/
Longest Valid Parentheses(最长有效的括号)
英文版:https://leetcode.com/problems/longest-valid-parentheses/
中文版:https://leetcode-cn.com/problems/longest-valid-parentheses/
Evaluate Reverse Polish Notatio(逆波兰表达式求值)
英文版:https://leetcode.com/problems/evaluate-reverse-polish-notation/
中文版:https://leetcode-cn.com/problems/evaluate-reverse-polish-notation/
队列
Design Circular Deque(设计一个双端队列)
英文版:https://leetcode.com/problems/design-circular-deque/
中文版:https://leetcode-cn.com/problems/design-circular-deque/
Sliding Window Maximum(滑动窗口最大值)
英文版:https://leetcode.com/problems/sliding-window-maximum/
中文版:https://leetcode-cn.com/problems/sliding-window-maximum/
递归
Climbing Stairs(爬楼梯)
英文版:https://leetcode.com/problems/climbing-stairs/
中文版:https://leetcode-cn.com/problems/climbing-stairs/
网友评论