摘要:
207、课程表 class Solution { public List<Integer>[] edges; public int[] ls; public boolean flag = true; public boolean canFinish(int numCourses, int[][] p 阅读全文
摘要:
#基本类型、包装类、字符串之间的转换 1、基本类型和包装类 基本类型和包装类可通过自动装箱和拆箱实现。 int i = 24; Integer a = new Integer(i); //手动装箱 Integer b = i; //自动装箱 int x = a; //自动拆箱 int y = a.i 阅读全文
摘要:
数组:内存空间连续,数据类型统一,下标从0开始 二分查找 704 class Solution { public int search(int[] nums, int target) { // 方法一:暴力解法 // for(int i = 0; i < nums.length; i++){ // 阅读全文
摘要:
#贪心算法 刷题或者面试的时候,手动模拟一下感觉可以局部最优推出整体最优,而且想不到反例,那么就试一试贪心。 455、分发饼干 class Solution { public int count; public int findContentChildren(int[] g, int[] s) { 阅读全文
摘要:
栈和队列:容器适配器,不提供迭代器 232、用栈实现队列 class MyQueue { Stack<Integer> stack1 = new Stack<>(); Stack<Integer> stack2 = new Stack<>(); public MyQueue() { } public 阅读全文
摘要:
链表:插入快,查询慢,存储不连续 分为单链表,双链表和循环链表 在链表中使用虚拟头结点,可以减少增删改查中对头结点的特殊处理 移除链表元素 203 /** * Definition for singly-linked list. * public class ListNode { * int val 阅读全文