ruijiege

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
  346 随笔 :: 0 文章 :: 8 评论 :: 12万 阅读
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

随笔分类 -  力扣算法

摘要:哔哩哔哩: 6.二次优化(3)_哔哩哔哩_bilibili 第一个版本对动态规划的理解 # 问题有大量的重复问题,比如求feibolaqie(5) = feibolaqie(4)+feibolaqie(3), # 所以有重复问题,通过缓存优化,把以前求过的问题做缓存 # def feibolaqie 阅读全文
posted @ 2023-05-21 16:34 哦哟这个怎么搞 阅读(38) 评论(0) 推荐(0) 编辑

摘要:public static int maxArea(int[] height) { int length = height.length; int left=0,right=length-1,max=0,area; while (left<right){ area = Math.min(height 阅读全文
posted @ 2021-08-23 10:54 哦哟这个怎么搞 阅读(141) 评论(0) 推荐(0) 编辑

摘要:package cn.jiedada;import org.junit.Test;import java.util.*;/**给定一个只包括 '(',')','{','}','[',']' 的字符串 s , * 判断字符串是否有效。有效字符串需满足:左括号必须用相同类型的右括号闭合。左括号必须以正确 阅读全文
posted @ 2021-08-03 07:55 哦哟这个怎么搞 阅读(26) 评论(0) 推荐(0) 编辑

摘要:public static boolean isValid(String s){ Map<Character, Character> map = new HashMap<>(); map.put('(',')'); map.put('{','}'); map.put('[',']'); Stack 阅读全文
posted @ 2021-08-03 07:41 哦哟这个怎么搞 阅读(28) 评论(0) 推荐(0) 编辑

摘要:class Solution { String longestPalindrome(String s) { //边界条件判断 if (s.length() < 2) return s; //start表示最长回文串开始的位置, //maxLen表示最长回文串的长度 int start = 0, ma 阅读全文
posted @ 2021-08-01 10:29 哦哟这个怎么搞 阅读(36) 评论(0) 推荐(0) 编辑

摘要:/** * 因为求第三大的数,所以需要一个指针存放第三大的 * 如果后面的数大于最大数和第二大的数都需要把最大数,第二大,的数移动 * @param nums * @return */ public static int thirdMax(int[] nums) { if (nums.length= 阅读全文
posted @ 2021-07-31 08:13 哦哟这个怎么搞 阅读(25) 评论(0) 推荐(0) 编辑

摘要:public ListNode middleNode(ListNode head) { ListNode slow =head, fast =head; while (fast!=null || fast.next != null){ slow = slow.next; fast = fast.ne 阅读全文
posted @ 2021-07-31 07:20 哦哟这个怎么搞 阅读(28) 评论(0) 推荐(0) 编辑

摘要:public static void rotate(int[] nums, int k) { k = k%nums.length; reverse(nums,0,nums.length); reverse(nums,0,k); reverse(nums,k,nums.length); } publi 阅读全文
posted @ 2021-07-30 22:07 哦哟这个怎么搞 阅读(27) 评论(0) 推荐(0) 编辑

摘要:/** * 思想简单,用一个指针指向第二个重复的字符即可,然后判断每一段的大小,通过map保存没有重复字符的索引 */ public static int lengthOfLongestSubstring(String s) { int pre=0,maxlen=0; Map<Character, 阅读全文
posted @ 2021-07-29 22:44 哦哟这个怎么搞 阅读(30) 评论(0) 推荐(0) 编辑

摘要:public static int[] twoSum(int[] nums, int target) { Map<Integer,Integer> map = new HashMap(); int[] a = new int[2]; for (int i = 0; i < nums.length; 阅读全文
posted @ 2021-07-23 16:59 哦哟这个怎么搞 阅读(32) 评论(0) 推荐(0) 编辑

摘要:public static int[] sortedSquares(int[] nums) { //定义一个双指针 int left=0,right=nums.length-1; int[] res = new int[right+1]; //因为新数组需要排序 for (int i = nums. 阅读全文
posted @ 2021-07-23 16:39 哦哟这个怎么搞 阅读(24) 评论(0) 推荐(0) 编辑

摘要:https://leetcode-cn.com/problems/first-bad-version/ public int firstBadVersion(int n) { int left=0,right=n,mid; while (left<right){ mid = ((right-left 阅读全文
posted @ 2021-07-22 17:47 哦哟这个怎么搞 阅读(21) 评论(0) 推荐(0) 编辑

摘要:public static int search(int[] nums, int target) { //双指针 int left=0,right=nums.length-1; int mid=0; int res = -1; while (left<=right){ //防止int溢出如果是写为( 阅读全文
posted @ 2021-07-22 17:40 哦哟这个怎么搞 阅读(31) 评论(0) 推荐(0) 编辑

摘要:package cn.jiedada.controller; import java.util.ArrayList; import java.util.List; import java.util.Stack; /** * 爬楼梯 */ class Solution { public static 阅读全文
posted @ 2021-07-20 20:03 哦哟这个怎么搞 阅读(28) 评论(0) 推荐(0) 编辑

摘要:package cn.jiedada.controller; import java.util.ArrayList; import java.util.List; import java.util.Stack; /** * 数的中序遍历 */ class Solution { public stat 阅读全文
posted @ 2021-07-20 19:33 哦哟这个怎么搞 阅读(21) 评论(0) 推荐(0) 编辑

摘要:三个概念:最有子结构,边界,状态转化 https://www.cnblogs.com/cthon/p/9251909.html 爬楼梯问题 public static int getWay(int i) { if (i<1){ return 1; } if (i==1){ return 1; } i 阅读全文
posted @ 2021-07-20 08:41 哦哟这个怎么搞 阅读(23) 评论(0) 推荐(0) 编辑

摘要:package cn.jiedada.controller; import java.util.ArrayList; import java.util.List; import java.util.Stack; /** * 数的中序遍历 */ class Solution { public List 阅读全文
posted @ 2021-07-20 08:07 哦哟这个怎么搞 阅读(78) 评论(0) 推荐(0) 编辑

摘要:package cn.jiedada.controller; /** * 两数相加 * */ class Solution { public ListNode addTwoNumbers(ListNode l1, ListNode l2) { //临时变量存储数据 ListNode p1=l1, p 阅读全文
posted @ 2021-07-15 11:31 哦哟这个怎么搞 阅读(43) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示