自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(22)
  • 收藏
  • 关注

原创 贪心-demo3

无重叠区间3.划分字母区间 leetcode 7634.合并区间 leetcode 565.单调递增的数字 leetcode 7386.买卖股票的最佳时机含手续费 leetcode 714

2022-06-13 21:33:04 282

原创 贪心-demo2

贪心-demo2(代码随想录)

2022-06-07 19:27:29 299

原创 贪心算法-demo1

贪心demo1

2022-06-05 20:59:24 316

原创 回溯-全排列、其他

回溯算法之全排列

2022-06-01 21:46:00 167

原创 回溯-子集

回溯算法之子集两例

2022-06-01 19:37:52 106

原创 回溯-分割

分割回文串,我们这时传入的start是切割线,比如abc,当start=0时切割:a|bc,当是回文的时候就加入temp,反之则看下一次切割情况。其余的和之前的回溯法没什么区别。

2022-05-31 22:04:24 217

原创 回溯-组合问题

针对回溯法,要把问题具象化为树结构。(第2题的树结构)1.组合问题 leetcode 77class Solution { List<List<Integer>> res = new ArrayList<>(); List<Integer> temp = new ArrayList<>(); public List<List<Integer>> combine(int n, int k) {

2022-05-31 20:24:10 407

原创 二叉树(5)

1.二叉搜索树中的众数 leetcode 501#递归class Solution { List<Integer> res1 = new ArrayList<>(); int max_count=-1; int cur_count=0; TreeNode pre=null; public int[] findMode(TreeNode root) { travesal(root); int[]res = ne

2022-05-25 21:59:34 108

原创 二叉树(4)

1.最大二叉树 leetcode 654class Solution { public TreeNode constructMaximumBinaryTree(int[] nums) { return constructMax(nums,0,nums.length); } public TreeNode constructMax(int[] nums,int start,int end){ if(end-start==0){

2022-05-20 21:03:22 114

原创 二叉树(3)

1.平衡二叉树 leetcode 110//递归,左子树和右子树同时平衡,则判断当前结点的左子树和右子树高度//左子树和右子树有不平衡的,直接返回falseclass Solution { public boolean isBalanced(TreeNode root) { if(root==null){ return true; } if(isBalanced(root.left)&&isBalance

2022-05-19 22:05:22 107

原创 二叉树(2)

1.翻转二叉树 leetcode 226//递归 后序class Solution { public TreeNode invertTree(TreeNode root) { invert(root); return root; } public void invert(TreeNode root){ if(root==null){ return; } invert(root

2022-05-18 20:44:30 144

原创 二叉树(基础遍历)

二叉树(遍历)1.递归遍历class Solution {//前序遍历 List<Integer> res = new ArrayList<>(); public List<Integer> preorderTraversal(TreeNode root) { pre(root); return res; } public void pre(TreeNode root){ if(root

2022-05-16 20:19:42 186

原创 栈与队列(下)

1.滑动窗口最大值 leetcode 239class Solution { public int[] maxSlidingWindow(int[] nums, int k) { int[] res = new int[nums.length-k+1]; Deque<Integer> myDeque = new LinkedList<>(); int id = 0; for(int i=0;i<nums

2022-05-08 20:52:11 520

原创 栈与队列(上)

1.用栈实现队列 leetcode 232class MyQueue { Stack<Integer> s1; Stack<Integer> s2; public MyQueue() { s1 = new Stack<>(); s2 = new Stack<>(); } public void push(int x) { s1.push(x); }

2022-05-07 21:48:15 81

原创 字符串(内含KMP)

字符串1.反转字符串leetcode 344class Solution { public void reverseString(char[] s) { // 双指针 int left = 0; int right = s.length-1; while(left<right){ char c = s[left]; s[left] = s[right];

2022-05-06 21:02:59 196

原创 哈希表(下)

哈希表(下)1.两数之和leetcode 1

2022-05-03 22:00:58 197

原创 哈希表(上 代码随想录二刷总结)

哈希表(上)1.有效的字母异位词leetcode 242class Solution { public boolean isAnagram(String s, String t) { int[] hash = new int[26]; //字符串s放入hash中 for(int i=0;i<s.length();i++){ hash[s.charAt(i)-'a']++; } //

2022-05-01 22:08:11 791

原创 链表篇(下 代码随想录二刷+总结)

链表篇(下 代码随想录二刷+总结)1.删除链表的倒数第N个结点leetcode 19class Solution { public ListNode removeNthFromEnd(ListNode head, int n) { ListNode first = head; ListNode second = head; ListNode virtue = new ListNode(-1,head); for(int i=0;

2022-04-29 20:50:50 880

原创 链表篇(上 代码随想录二刷+总结)

链表篇(上 代码随想录二刷+总结)1.移除链表元素leetcode 203class Solution { public ListNode removeElements(ListNode head, int val) { ListNode newHead = new ListNode(0,head); ListNode pre = newHead; while(head!=null){ if(head.val==val)

2022-04-28 22:16:23 848

原创 滑动窗口两例

滑动窗口1.长度最小的子数组在之前已经做过点这里2.水果成蓝leetcode 904你正在探访一家农场,农场从左到右种植了一排果树。这些树用一个整数数组 fruits 表示,其中 fruits[i] 是第 i 棵树上的水果 种类 。你想要尽可能多地收集水果。然而,农场的主人设定了一些严格的规矩,你必须按照要求采摘水果:你只有 两个 篮子,并且每个篮子只能装 单一类型 的水果。每个篮子能够装的水果总量没有限制。你可以选择任意一棵树开始采摘,你必须从 每棵 树(包括开始采摘的树)上 恰好摘一个水果

2022-04-27 22:13:01 200

原创 数组篇(代码随想录二刷+总结)

数组篇(代码随想录二刷+总结)1.二分查找leetcode 704给定一个 n 个元素有序的(升序)整型数组 nums 和一个目标值 target ,写一个函数搜索 nums 中的 target,如果目标值存在返回下标,否则返回 -1。 public int search(int[] nums, int target) { int left = 0; int right = nums.length; while(left<right){

2022-04-25 22:02:19 230

原创 SSM整合(以图书管理系统为例)

SSM整合(以图书管理系统为例)

2022-04-15 15:01:39 981 1

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除