摘要: 207、课程表 class Solution { public List<Integer>[] edges; public int[] ls; public boolean flag = true; public boolean canFinish(int numCourses, int[][] p 阅读全文
posted @ 2023-04-16 11:24 novice_programmer_oo 阅读(18) 评论(0) 推荐(0)
摘要: #基本类型、包装类、字符串之间的转换 1、基本类型和包装类 基本类型和包装类可通过自动装箱和拆箱实现。 int i = 24; Integer a = new Integer(i); //手动装箱 Integer b = i; //自动装箱 int x = a; //自动拆箱 int y = a.i 阅读全文
posted @ 2023-03-23 17:31 novice_programmer_oo 阅读(64) 评论(0) 推荐(0)
摘要: 数组:内存空间连续,数据类型统一,下标从0开始 二分查找 704 class Solution { public int search(int[] nums, int target) { // 方法一:暴力解法 // for(int i = 0; i < nums.length; i++){ // 阅读全文
posted @ 2023-03-21 18:50 novice_programmer_oo 阅读(50) 评论(0) 推荐(0)
摘要: #动态规划 如果某一问题有很多重叠子问题,使用动态规划是最有效的 解题步骤: 背包问题:01背包,完全背包,多重背包 01背包: 统一使用一维数组来进行遍历 public static void main(String[] args) { int[] weight = {1, 3, 4}; int[ 阅读全文
posted @ 2023-01-11 21:51 novice_programmer_oo 阅读(98) 评论(0) 推荐(0)
摘要: #贪心算法 刷题或者面试的时候,手动模拟一下感觉可以局部最优推出整体最优,而且想不到反例,那么就试一试贪心。 455、分发饼干 class Solution { public int count; public int findContentChildren(int[] g, int[] s) { 阅读全文
posted @ 2022-12-23 11:55 novice_programmer_oo 阅读(71) 评论(0) 推荐(0)
摘要: #回溯算法 回溯的本质是穷举,所以不是高效的算法 回溯法,一般可以解决如下几种问题: 组合问题:N个数里面按一定规则找出k个数的集合 注意区分一个集合取组合和多个集合取组合的细节。 切割问题:一个字符串按一定规则有几种切割方式 子集问题:一个N个数的集合里有多少符合条件的子集 排列问题:N个数按一定 阅读全文
posted @ 2022-12-13 22:05 novice_programmer_oo 阅读(69) 评论(0) 推荐(0)
摘要: 二叉树: 种类:满二叉树、完全二叉树、二叉搜索树、平衡二叉搜索树 存储方式:链式存储、线式存储(顺序存储) 二叉数遍历:深度优先搜索(前序、中序、后序):使用递归实现(实际用栈来实现)、迭代法(非递归的方式、栈),广度优先搜索(层序遍历):用队列 递归三步走写法:1、确定递归函数的参数和返回值。2、 阅读全文
posted @ 2022-12-04 19:45 novice_programmer_oo 阅读(67) 评论(0) 推荐(0)
摘要: 栈和队列:容器适配器,不提供迭代器 232、用栈实现队列 class MyQueue { Stack<Integer> stack1 = new Stack<>(); Stack<Integer> stack2 = new Stack<>(); public MyQueue() { } public 阅读全文
posted @ 2022-11-21 08:53 novice_programmer_oo 阅读(23) 评论(0) 推荐(0)
摘要: 字符串: 反转字符串 344 class Solution { public void reverseString(char[] s) { // 左右指针 int leftNode = 0; int rifhtNode = s.length - 1; char temp; while(leftNod 阅读全文
posted @ 2022-11-13 19:40 novice_programmer_oo 阅读(27) 评论(0) 推荐(0)
摘要: 链表:插入快,查询慢,存储不连续 分为单链表,双链表和循环链表 在链表中使用虚拟头结点,可以减少增删改查中对头结点的特殊处理 移除链表元素 203 /** * Definition for singly-linked list. * public class ListNode { * int val 阅读全文
posted @ 2022-11-04 21:57 novice_programmer_oo 阅读(71) 评论(0) 推荐(0)