自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 8255

2020-04-27 14:38:13 441

原创 斐波那契数列

法一:递归(超时)class Solution {public: int Fibonacci(int n) { if(n <=1 ) return n; return Fibonacci(n-1) + Fibonacci(n-2); }};法二:存储计算过的每一个fiboclass Solution {public: ...

2020-03-31 13:10:43 210

原创 BIOS中断、DOS中断、Linux中断的区别

BIOS中断、DOS中断、Linux中断的区别

2020-03-10 19:53:11 643

原创 uCore Lab1

练习一:问题1:操作系统镜像文件ucore.img是如何一步一步生成的?cc kern/init/init.c //编译 init.ccc kern/libs/readline.c //编译 readline.ccc kern/libs/stdio.c //编译 stdio.ccc kern/debug/kdebug.c//编译 kdebug.ccc kern/d...

2020-03-06 23:05:30 190

原创 Loader引导加载程序

Q1:内核程序起始地址为什么位于物理地址0x100000(1MB)处:A:因为在1MB以下的物理地址并不全是可用内存地址空间,有内存空间,非内存空间以及地址空洞;所以为了避开这些纷繁复杂的内存地址,选择了从平坦的1MB地址开始.一,1,开启1MB以上物理地址寻址功能,同时开启实模式下的4GB的寻址功能;2,加载kernal.bin进入内存1MB开始的位置处;现将kernal.bin一簇一簇...

2020-02-24 17:32:53 613

原创 从Boot跳转到loader程序

将上一节的boot.asm程序的Label_File_Loaded:函数改写Label_File_Loaded: //完成了向Loader引导加载程序移交执行权的工作 jmp BaseOfLoader:OffsetOfLoader在编写一个loader.asm程序org 10000h mov ax, cs mov ds, ax mov es, ax mov ax, 0x00...

2020-02-23 20:16:35 411

原创 Boot.asm完整版

boot程序要完成的功能1,将软盘格式化为FAT12文件系统2,在FAT12文件系统的软盘中找到loader.bin3,加载loader.bin到内存特定的位置上用nasm编译器将boot.asm 编译为对应的boot.bin文件nasm boot.asm -o boot.bin重新将boot.bin写入软盘 dd if=boot.bin of=/home/hjw/Download...

2020-02-23 16:59:48 1809

原创 软件工程(C 实践)

Vim三种模式:基本上 vi/vim 共分为三种模式,分别是命令模式(Command mode),输入模式(Insert mode)和底线命令模式(Last line mode)。 这三种模式的作用分别是:实践内容:实现可以广泛通用的命令行菜单子系统组件实验环境:ubuntu + vim编辑器实验语言:c...

2020-02-22 10:28:05 163

原创 763. 划分字母区间(贪心)

2020-02-19 22:16:25 95

原创 53. 最大子序和(贪心)

2020-02-19 22:15:41 156

原创 665. 非递减数列(贪心)

2020-02-19 22:14:52 86

原创 392. 判断子序列(贪心)

2020-02-19 22:14:05 129

原创 605. 种花问题(贪心)

2020-02-19 22:13:18 113

原创 122. 买卖股票的最佳时机 II(贪心)

方法一:贪心class Solution { public int maxProfit(int[] prices) { int profit = 0; for(int i = 1;i<prices.length;i++){ if(prices[i] - prices[i-1] >0) ...

2020-02-18 21:45:31 101

原创 121. 买卖股票的最佳时机(贪心)

方法一:一次遍历我们可以维持两个变量——minprice 和 maxprofit,它们分别对应迄今为止所得到的最小的谷值和最大的利润class Solution { public int maxProfit(int[] prices) { int minPrice = Integer.MAX_VALUE; int maxProfit...

2020-02-18 21:44:26 106

原创 406. 根据身高重建队列(贪心)

思路:按身高降序排序,按k值升序排序;顺序遍历,将people元素插入(用LinkedList.add(int index, int element))people[ ][1]对应的位置处;class Solution { public int[][] reconstructQueue(int[][] people) { Arrays.sort(people,new...

2020-02-18 21:43:21 113

原创 452. 用最少数量的箭引爆气球(贪心)(同无重叠区间)

思路完全同LeetCode 435. 无重叠区间(贪心)只改变一点:在区间的交界点,气球都会被射爆class Solution { public int findMinArrowShots(int[][] points) { if(points.length == 0) return 0; Arrays.sort(points,new...

2020-02-18 21:41:32 93

原创 435. 无重叠区间(贪心)

思路:1,从区间集合 intvs 中选择一个区间 x,这个 x 是在当前所有区间中结束最早的(end 最小)。2,把所有与 x 区间相交的区间从区间集合 intvs 中删除。3,重复步骤 1 和 2,直到 intvs 为空为止。之前选出的那些 x 就是最大不相交子集。class Solution { public int eraseOverlapIntervals(int[][...

2020-02-17 23:24:04 135

原创 455. 分发饼干(贪心)

class Solution { public int findContentChildren(int[] g, int[] s) { Arrays.sort(g); Arrays.sort(s); int i = 0,j = 0; while(i<g.length && j <s.length...

2020-02-17 23:23:09 144

原创 75. 颜色分类(排序)(荷兰国旗问题)

荷兰国旗问题:方法一:本解的关键点:因为curr左边的值已经扫描过了,所以curr要++继续扫描下一位,而与p2交换的值,curr未扫描,要停下来扫描一下,所以curr不用++。class Solution { public void sortColors(int[] nums) { int p0= 0,cur = 0,p2 = nums.length-1;...

2020-02-17 23:21:54 139

原创 451. 根据字符出现频率排序(排序)(堆排序)

方法一: 哈希表+堆排序class Solution { public String frequencySort(String s) { HashMap<Character,Integer> map = new HashMap<>(); for(int i =0;i<s.length();i++){ ...

2020-02-17 23:20:55 132

原创 347. 前 K 个高频元素(排序)(堆排序)

方法一:用哈希表记下每个元素的频率。然后用大小最大为k的小根堆存储元素,从而找到前k个高频元素。class Solution { public List<Integer> topKFrequent(int[] nums, int k) { HashMap<Integer,Integer> map = new HashMap<>();...

2020-02-16 23:09:21 96

原创 215. 数组中的第K个最大元素(排序)(快速选择排序[复习])

方法一:排序,计数器class Solution { public int findKthLargest(int[] nums, int k) { Arrays.sort(nums); return nums[nums.length-k]; }}方法二: 用堆最小堆 + 维护一个只有k个元素;class Solution { ...

2020-02-16 23:08:35 106

原创 524. 通过删除字母匹配到字典里最长单词(双指针)

方法一:排序 + 找子串问题中匹配的条件是我们需要考虑字典中能匹配的最长字符串,相同长度的情况下考虑字典序最小的。为了简化搜索过程,我们把字典中的字符串按照这一规则排序,这样越靠前的字符串是我们越优先考虑的。现在,与其删除 ss 中的字符,我们直接从头开始检查字典中的单词是否是 ss 串的子序列。这是因为,如果 xx 是 ss 的子序列,我们可以直接通过删除 ss 中的某些字符得到 xx 。...

2020-02-16 23:06:57 121

原创 141. 环形链表(双指针)(哈希表)

方法一:哈希表/** * Definition for singly-linked list. * class ListNode { * int val; * ListNode next; * ListNode(int x) { * val = x; * next = null; * } * } */pub...

2020-02-16 16:57:58 125

原创 88. 合并两个有序数组(双指针)

方法一:从头开始遍历,需要额外的o(n)的空间在这里插入代码片class Solution {public void merge(int[] nums1, int m, int[] nums2, int n) {int[] nums1tmp = new int[m];for(int i = 0;i<m;i++){nums1tmp[i] = nums1[i];} i...

2020-02-15 12:03:26 157

原创 680. 验证回文字符串 Ⅱ(双指针)

删除操作不一定要真的删除,可以逻辑上删除class Solution { public boolean validPalindrome(String s) { int i = 0,j = s.length()-1,deleteCnt = 0; while(i<j){ if(s.charAt(i)!=s.charAt(j)...

2020-02-15 11:32:58 98

原创 345. 反转字符串中的元音字母(双指针)

思路:双指针两种写法存结果:1,用stringBuilder;2,用字符类型数组class Solution {private final static HashSet<Character> vowels = new HashSet<>( Arrays.asList('a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', '...

2020-02-15 10:49:05 88

原创 633. 平方数之和 (双指针)

方法一:双指针思路类似LeetCode 167 两数之和II不同的时,这里对j进行了剪枝,j初始化为 (int)Math.sqrt©;class Solution { public boolean judgeSquareSum(int c) { if(c<0) return false; int i = 0, j = (int)Math.s...

2020-02-15 10:18:06 165

原创 677. 键值映射(前缀树)

2020-02-14 22:48:20 81

原创 208. 实现 Trie (前缀树) (未完成)

2020-02-14 22:46:00 68

原创 501. 二叉搜索树中的众数(树)(BST)(回看)

/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */class Solution { pri...

2020-02-14 11:52:23 88

原创 530. 二叉搜索树的最小绝对差(树)(BST)

方法一:(中序遍历+额外o(n)的存储空间)中序遍历BST ,得到的序列有序,所有相邻结点差的绝对值的最小值就是要找的结果/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * ...

2020-02-14 10:11:25 111

原创 167. 两数之和 II - 输入有序数组(双指针)

思路class Solution { public int[] twoSum(int[] numbers, int target) { int[] res = {-1,-1}; int i = 0,j = numbers.length-1; while(i<j){ int k = numbers[i]+num...

2020-02-13 13:07:01 80

原创 653. 两数之和 IV - 输入 BST(树)(BST)(有序数组的两数之和)

方法一:将BST的值存储到HashMap中,转化为 两数和为目标值的问题;LeetCode 1 两数之和/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode...

2020-02-13 12:56:46 83

原创 109. 有序链表转换二叉搜索树(树)(BST)(模拟中序遍历)

方法一:思路类似 LeetCode 108也是每次加入中间元素;只是改成了链表,不能随机存取;使用快慢指针找到链表的中间结点;递归构造平衡BST注意点:要添加终止条件: if(head == mid) return root;如果不添加这个条件,当链表只有一个结点时,将无限循环递归(原因时在递归时传入的参数head 始终不改变,执行结果一样)/** * Definitio...

2020-02-13 11:30:49 194

原创 108. 将有序数组转换为二叉搜索树(树)(BST)(回看)

关键点,对一个有序数组,要想构造一棵 平衡BST,必须从中间的结点开始;选取中间点可以随意选,构造的平衡BST不唯一/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * T...

2020-02-12 23:51:03 76

原创 236. 二叉树的最近公共祖先(树)

/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */class Solution { pr...

2020-02-12 12:59:58 124

原创 235. 二叉搜索树的最近公共祖先(树)(BST)

要利用 BST的性质/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */class Solutio...

2020-02-12 11:42:16 101

原创 538. 把二叉搜索树转换为累加树(树)

遍历顺序,右根左/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */class Solution ...

2020-02-12 10:23:44 116

空空如也

空空如也

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

TA关注的人

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