摘要: 参考blog指路:https://blog.csdn.net/xiao_a_ruo_ya/article/details/98850706 Java集合又称为容器,用于存储、提取、删除数据。JDK提供的集合API都包含在 java.util 包内。 集合的分支: 集合框架两大分支:Collectio 阅读全文
posted @ 2022-03-13 22:06 Dreamer_szy 阅读(36) 评论(0) 推荐(0)
摘要: LinkedList其实也就是我们在数据结构中的链表,这种数据结构有这样的特性: 分配内存空间不是必须是连续的; 插入、删除操作很快,只要修改前后指针就OK了,时间复杂度为O(1); 访问比较慢,必须得从第一个元素开始遍历,时间复杂度为O(n); 添加元素 add boolean add(E e): 阅读全文
posted @ 2022-03-13 19:51 Dreamer_szy 阅读(53) 评论(0) 推荐(0)
摘要: /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ 阅读全文
posted @ 2022-03-13 19:40 Dreamer_szy 阅读(24) 评论(0) 推荐(0)
摘要: class MinStack { /** initialize your data structure here. */ private Stack<Integer> minStack; private Stack<Integer> helpStack; public MinStack() { mi 阅读全文
posted @ 2022-03-13 15:56 Dreamer_szy 阅读(23) 评论(0) 推荐(0)
摘要: class Solution { public int minArray(int[] numbers) { int start=0,end=numbers.length-1; int mid=0; while(start<end){ mid=start+(end-start)/2; if(numbe 阅读全文
posted @ 2022-03-13 10:16 Dreamer_szy 阅读(18) 评论(0) 推荐(0)
摘要: class Solution { public int findMin(int[] nums) { int start=0; int end=nums.length-1; int mid=0; while(start<end){ mid=start+(end-start)/2; //只使用相邻的mi 阅读全文
posted @ 2022-03-13 10:01 Dreamer_szy 阅读(22) 评论(0) 推荐(0)
摘要: while比for的效率更低 class Solution { public int[] reversePrint(ListNode head) { Stack<Integer> stack=new Stack<Integer>(); if(head==null){ return new int[0 阅读全文
posted @ 2022-03-13 10:01 Dreamer_szy 阅读(20) 评论(0) 推荐(0)
摘要: 动态规划就是为了避免多次重复的计算,也就是保留历史数据,这个历史记录的数据格式可以使用一维或者二维的数组进行保存。 动态规划分为以下三步: 一、定义dp数组的意义 即明确这个dp数组的各个元素代表的是什么意思 二、找出各数组元素之间的关系式 动态规划,还是有一点类似于我们高中学习时的归纳法的,当我们 阅读全文
posted @ 2022-03-12 13:19 Dreamer_szy 阅读(77) 评论(0) 推荐(0)
摘要: class Solution { public int numWays(int n) { if(n==0){ return 1; } if(n<=2){ return n; } int[] dp=new int[n+1]; dp[0]=1; dp[1]=1; dp[2]=2; //随着 nn 增大, 阅读全文
posted @ 2022-03-12 13:11 Dreamer_szy 阅读(20) 评论(0) 推荐(0)
摘要: class Solution { public boolean isSubStructure(TreeNode A, TreeNode B) { boolean result=false; if(A!=null&&B!=null){ if(A.val==B.val){ result=isTrue(A 阅读全文
posted @ 2022-03-12 09:26 Dreamer_szy 阅读(12) 评论(0) 推荐(0)