自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

翻译 Operating System - I/O Hardware

Operating System - I/O Hardware操作系统的一个很重要的工作就是管理多种I/O设备包括鼠标,键盘,触摸板,磁盘驱动,显示器,USB设备,Bit-mapped屏幕,LED,模拟到数字转换器,开关,网络连接,音频I/O,打印机等等。一个操作系统有责任接纳一个应用程序的I/O请求并将其发送到物理设备,然后把不管那个设备返回的回复是什么,将它发送到该应用程序。I/O设备可以...

2020-02-29 14:45:29 274

翻译 FlashText算法:在文本中大规模检索或替换关键字的高效率算法

摘要对于一个document,size是N个characters,和一个包含了M个关键字的字典,在这个document里替换或者找到这些关键字,如果用正则匹配的方式,时间复杂度应该是O(M*N)。而FlashText算法的时间复杂度可以达到O(N)。与Aho Corasick不同,FlashText算法不会匹配sub-strings。FlashText被设计来只匹配完整的单词(两边都有边界...

2019-03-13 16:32:02 3188

原创 Leetcode 429. N叉树的层序遍历

注意queue不断改变,先用n存下queue的大小。第二点是要对root进行判断是否为空。/*// Definition for a Node.class Node {public: int val = NULL; vector<Node*> children; Node() {} Node(int _val, vector<N...

2018-07-23 14:43:24 1008

原创 Leetcode 700. 二叉搜索树中的搜索

给定二叉搜索树(BST)的根节点和一个值。 你需要在BST中找到节点值等于给定值的节点。 返回以该节点为根的子树。 如果节点不存在,则返回 NULL。例如,给定二叉搜索树: 4 / \ 2 7 / \ 1 3和值: 2你应该返回如下子树: 2 / \ 1 ...

2018-07-19 20:20:00 921

原创 Leetcode 515. 在每个树行中找最大值

思路:简单的二叉树层次遍历的推广。二叉树层次遍历是典型的广度优先搜索(BFS)的应用。代码如下:/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : v...

2018-07-14 23:05:33 236

原创 Leetcode 287. 寻找重复数

Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate number, f...

2018-07-14 22:57:41 948 2

转载 Convertion of grey code and binary 格雷码和二进制数之间的转换

摘自维基百科的转换代码:/* The purpose of this function is to convert an unsingned binary number to reflected binary Grey code.*/unsigned int binary2Grey(unsigned int num){ return (num>>1)^num...

2018-07-14 10:53:23 238

原创 Leetcode 442. 数组中重复的数据

题目:给定一个整数数组 a,其中1 ≤ a[i] ≤ n (n为数组长度), 其中有些元素出现两次而其他元素出现一次。找到所有出现两次的元素。你可以不用到任何额外空间并在O(n)时间复杂度内解决这个问题吗?思路:这类问题的重要条件是1 ≤ a[i] ≤ n。class Solution {public: vector<int> findDuplicates(vector&lt...

2018-07-14 10:28:39 1241

原创 Leetcode 797. All Paths From Source to Target

class Solution {public: vector<vector<int>> allPathsSourceTarget(vector<vector<int>>& graph) { vector<vector<int>> res; vector<int&g

2018-07-13 23:30:35 115

原创 Leetcode 859.亲密字符串

class Solution {public: bool buddyStrings(string A, string B) { int n1=A.size(),n2=B.size(); if(n1!=n2) return false; int ind1,ind2,cnt=0; vector<int> v(26,0...

2018-07-13 23:17:45 563

原创 Leetcode 861.翻转矩阵后的得分

class Solution {public: int matrixScore(vector<vector<int>>& A) { int m=A.size(),n=A[0].size(); int res=0, k=1; for(int i=0;i<m;++i){ if(A[i...

2018-07-13 23:16:27 355

空空如也

空空如也

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

TA关注的人

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