class Solution { public List<Integer> postorderTraversal(TreeNode root) { //一般解法,前序遍历后,翻转下结果集,注意下 与前序遍历的进栈顺序不一样 //(前序) 根左右 --> 变为 根右左 --> 翻转 左右根 (后续) ...
分类:
其他好文 时间:
2020-10-27 11:40:04
阅读次数:
20
Python自动的os库是和操作系统交互的库,常用的操作包括文件/目录操作,路径操作,环境变量操作和执行系统命令等。 文件/目录操作 获取当前目录(pwd): os.getcwd() 切换目录(cd): os.chdir('/usr/local/') 列出目录所有文件(ls):os.listdir( ...
分类:
编程语言 时间:
2020-10-27 11:33:55
阅读次数:
30
Python是进行数据分析的一种出色语言,主要是因为以数据为中心的Python软件包具有奇妙的生态系统。Pandas是其中的一种,使导入和分析数据更加容易。 让我们看看在Pandas Dataframe中遍历行的不同方法: 方法#1:使用Dataframe的index属性。 # import pan ...
分类:
其他好文 时间:
2020-10-26 11:38:27
阅读次数:
23
1. StudenDaoListImpl.java与StudentDaoArrayImpl.java有何不同?StudenDaoListImpl.java使用的数据结构是数组,而StudentDaoArrayImpl.java使用的数据的结构是链表,在查找和添加过程中,只需遍历链表查找,在最后添加, ...
分类:
其他好文 时间:
2020-10-26 11:28:50
阅读次数:
16
1 class Solution: 2 def longestMountain(self, A: List[int]) -> int: 3 n = len(A) 4 left = [0] * n # 初始化 5 for i in range(1, n): 6 left[i] = (left[i - ...
分类:
其他好文 时间:
2020-10-26 11:28:01
阅读次数:
20
题目介绍 给定二叉树,将其原地变成一个链表。 Example: 1 / \ 2 5 / \ \ 3 4 6 1 \ 2 \ 3 \ 4 \ 5 \ 6 Solutions 直观解法 发现链表的结果与先序遍历一致,因此先进行先序遍历,再根据遍历的结果构造链表。 # Definition for a b ...
分类:
其他好文 时间:
2020-10-26 11:17:57
阅读次数:
15
分治思想: 我有一万个元素,查找其中的一个元素,最简单的遍历方法 复杂度为O(4) (遍历四次),如何实现 准备2500个数组 查找x 补充知识:什么是hash & 什么是hashCode https://blog.csdn.net/weixin_38405253/article/details/9 ...
分类:
其他好文 时间:
2020-10-26 11:13:38
阅读次数:
17
1. 深度优先遍历 使用场景:常见于各种组合,树遍历,前序遍历、中序遍历、后续遍历 private void dfs(int[] arr, int target,int begin, Deque<Integer> path, Set<List<Integer>> res) { if ( path.s ...
分类:
编程语言 时间:
2020-10-26 10:56:27
阅读次数:
26
以ArrayList为例。 List<Integer> list = new ArrayList<>(); for(int i=0;i<11;i++){ List.add(i);} 遍历方式一:普通for循环(适合ArrayList。) for(int i=0;i<list.size();i++){ ...
分类:
其他好文 时间:
2020-10-26 10:41:31
阅读次数:
24
二叉树的后续遍历(Leetcode 145) 数据结构定义: // Definition for a binary tree node. public class TreeNode { int val; TreeNode left; TreeNode right; TreeNode() {} Tre ...
分类:
其他好文 时间:
2020-10-24 10:25:33
阅读次数:
22