随笔分类 - Java
摘要:题目: 请输入一个函数,输入一个整数,请输出该数的二进制表示中的1的个数。 解答:
阅读全文
摘要:题目: 给定一个二叉树和其中一个结点,如何找出中序遍历的下一个结点?树中的节点除了两个分别指向左、右子节点的指针外,还有一个指向父节点的指针。 解答:
阅读全文
摘要:题目: 输入一个整型数组,判断该数组是不是二叉搜索树的后序遍历结果。 如果是,返回true。否则返回false 解答:
阅读全文
摘要:题目: 输入某二叉树的前序遍历和中序遍历的结果,请重建出该二叉树。 解答:
阅读全文
摘要:题目: 请实现一个函数,用来判断一颗二叉树是不是对称的。如果一颗二叉树和它的镜像是一样的,那么它就是对称的。 解答:
阅读全文
摘要:1 public class Solution { 2 3 public static void MirrorBinaryTree(TreeNode root) { 4 if(root == null) { 5 return; 6 } 7 8 if(root.left == null && roo...
阅读全文
摘要:死锁? 死锁是指多个进程因竞争资源而造成的一种僵局(互相等待),若无外力作用,这些进程都将无法向前推进。例如,在某一个计算机系统中只有一台打印机和一台输入 设备,进程P1正占用输入设备,同时又提出使用打印机的请求,但此时打印机正被进程P2 所占用,而P2在未释放打印机之前,又提出请求使用正被P1占用
阅读全文
摘要:当你把对象加入HashSet时,HashSet会先计算对象的hashcode值来判断对象加入的位置,同时也会和其他加入的对象的hashcode值作比较,如果没有相符的hashcode,HashSet会假设对象没有重复出现,但是如果发现有相同的hashcode值的对象,这时候会调用equals方法来检
阅读全文
摘要:执行顺序: 父类 static 子类 static 父类普通代码块 父类 constructor 子类 普通代码块 子类 constructo
阅读全文
摘要:题目: Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in t
阅读全文
摘要:题目: Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or anothe
阅读全文
摘要:题目: Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) – Push element x onto stack. pop() – R
阅读全文
摘要:题目: Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999 解答:
阅读全文
摘要:题目: Given a matrix of m ✕ n elements (m rows, n columns), return all elements of the matrix in spiral order.For example, given the following matrix:[[
阅读全文
摘要:题目: Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example, given the below binary tree,1/ \2 4
阅读全文
摘要:题目: Given an array where elements are sorted in ascending order, convert it to BST 解答:
阅读全文

浙公网安备 33010602011771号