LeetCode
Smarticle
Happy and Tough
展开
-
LeetCode477 : 汉明距离总和
考察点: 位运算(异或操作对比位数差异、bitCount函数统计1个个数、位运算时的数学思维) public class LeetCode477totalHammingDistance { public static int totalHammingDistance(int[] nums) { int sum = 0; for (int i = 0; i < nums.length; i++) { for (int j=i+ 1;j原创 2021-05-29 09:22:27 · 271 阅读 · 0 评论 -
LeetCode94 : 二叉树的中序遍历
https://leetcode-cn.com/problems/binary-tree-inorder-traversal/ 考察点: 二叉树的中序遍历, 递归思考, 递归中全局list传入 import BasicDataStruct.TreeNode; import java.util.ArrayList; import java.util.List; public class LeetCode94inorderTraversal { public static List<Int原创 2021-05-27 18:48:59 · 140 阅读 · 0 评论 -
Leetcode 107 : 二叉树的层次遍历2
https://leetcode-cn.com/problems/binary-tree-inorder-traversal/ 考察点: 二叉树的层次遍历, 集合类的灵活应用 Collections 以及 list.add(0,)方法的灵活使用 import BasicDataStruct.TreeNode; import java.util.*; public class LeetCode107FLoorTraversal { public static L原创 2021-05-27 18:18:23 · 130 阅读 · 0 评论 -
Leetcode 102 : 二叉树的层序遍历
https://leetcode-cn.com/problems/binary-tree-level-order-traversal/submissions/ 考察点: 二叉树层次遍历、层次遍历中处理每层数据 import BasicDataStruct.TreeNode; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import java.util.Queue; public class原创 2021-05-27 17:47:11 · 122 阅读 · 0 评论 -
Leetcode 993 : 二叉树的堂兄弟节点
https://leetcode-cn.com/problems/cousins-in-binary-tree/ 考察点: 二叉树遍历、二叉树节点深度记录、二叉树当前节点父节点记录 import java.util.LinkedList; import java.util.Queue; public class BinaryTreeIsBrother { public static class TreeNode { int val; TreeNode left;原创 2021-05-27 16:47:57 · 157 阅读 · 0 评论