摘要:
先看题目 前序遍历N叉树,与前序遍历二叉树类似 可以使用递归或者栈,两种方法 1.使用递归 1 /* 2 // Definition for a Node. 3 class Node { 4 public int val; 5 public List<Node> children; 6 7 publ 阅读全文
摘要:
1.key为null import java.util.HashMap; public class Test{ public static void main(String[] args) { HashMap<Integer,String> map = new HashMap<>(); for(in 阅读全文
摘要:
先看题目 今天这道题没什么好说的了,单纯的进制转换,下图举了两个例子 1 class Solution { 2 public String convertToBase7(int num) { 3 int ans = 0; 4 int p = 0; 5 while(num != 0){ 6 int t 阅读全文
摘要:
遍历数组,记录下前缀的最大值和最小值。(这是看题解之前想出来的解法,看了题解之后发现和题解方法一差不多) class Solution { public long subArrayRanges(int[] nums) { int len = nums.length; long sum = 0L; f 阅读全文
摘要:
今天在使用StringBuilder时,当传入参数类型为char时,会调用如下构造方法 /** * Constructs a string builder with no characters in it and an * initial capacity specified by the {@co 阅读全文