返回顶部
摘要: # 递归相关知识2 ## 多路递归--斐波那契额数列 ```java import java.util.Arrays; //递归求斐波那契第n项 public class feibonaqie { public static int fibonacci(int n){ int []cache=new 阅读全文
posted @ 2023-07-14 21:00 全栈工程师cgy 阅读(45) 评论(0) 推荐(0) 编辑
摘要: # 2022蓝桥杯b组 ## A题 ![img](https://img-blog.csdnimg.cn/4ac63a09fe784d7a94b710fc0cc48d09.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50, 阅读全文
posted @ 2023-07-11 20:26 全栈工程师cgy 阅读(151) 评论(0) 推荐(0) 编辑
摘要: <!doctype html> <html> <head> <meta charset="utf-8"> <title>新年烟花</title> <style> html,body{ margin:0px; width:100%; height:100%; overflow:hidden; back 阅读全文
posted @ 2024-01-18 10:08 全栈工程师cgy 阅读(53) 评论(0) 推荐(0) 编辑
摘要: # 01背包问题 ```java public class KnapsackProblem { public static void main(String[] args) { int []w={1,2,3,4,5}; int[]value={3,4,6,8,10}; int capacity=10 阅读全文
posted @ 2023-07-26 19:50 全栈工程师cgy 阅读(23) 评论(0) 推荐(0) 编辑
摘要: # 合并有序数组 ## 方法1-递归 ```java //运用的思想就是比较谁大,谁就先被排进数组 public static void merge(int []a1,int i,int iEnd,int j,int jEnd, int []a2,int k){ //定义了一个a1数组,分了i,iE 阅读全文
posted @ 2023-07-19 20:56 全栈工程师cgy 阅读(39) 评论(0) 推荐(0) 编辑
摘要: # 回文比较 ## 步骤1.找中间点 ## 用到了查找链表中间节点-快慢指针法 ```java public ListNode middleNode (ListNode head){ ListNode p1=head; ListNode p2=head; while (p2!=null&&p2.ne 阅读全文
posted @ 2023-07-19 10:25 全栈工程师cgy 阅读(25) 评论(0) 推荐(0) 编辑
摘要: # 判环算法01 ## 检验链表是否有环 ```java //判断环 public boolean hasCycle(ListNode head){ ListNode p1=head;//乌龟 ListNode p2=head;//兔子 while (p2!=null&&p2.next!=null) 阅读全文
posted @ 2023-07-18 21:40 全栈工程师cgy 阅读(22) 评论(0) 推荐(0) 编辑
摘要: # 反转链表-力扣206 ## 方法一 ```java public ListNode reverseList1(ListNode o1){ ListNode n1=null; ListNode p=o1; while(p!=null){ n1=new ListNode(p.val,n1);//插入 阅读全文
posted @ 2023-07-17 21:40 全栈工程师cgy 阅读(30) 评论(0) 推荐(0) 编辑
摘要: # 递归 ## 递归小题练习 ```java public static int f(int n){ if(n==1){ return 1; } return n*f(n-1); } public static void main(String[] args) { int f=f(5); } ``` 阅读全文
posted @ 2023-07-13 21:34 全栈工程师cgy 阅读(26) 评论(0) 推荐(0) 编辑
摘要: ## 一.链表带哨兵 ```java import java.util.Iterator; import java.util.function.Consumer; //带哨兵 public class shuju02 implements Iterable {//整体 private Node he 阅读全文
posted @ 2023-07-12 21:19 全栈工程师cgy 阅读(48) 评论(0) 推荐(0) 编辑