自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 webassembly是什么?

WebAssembly 是一种可以使用非 JavaScript 编程语言编写代码并且能在浏览器上运行的技术方案。您可能会将WebAssembly当做是另外一种目标汇编语言。这是真的,这些机器语言(x86,ARM等)中的每一种都对应于特定的机器架构。当你的代码运行在用户的机器的web平台上的时候,你不知道你的代码将会运行在那种机器结构上。所以WebAssembly和别的汇编语言是有一些不同的。所以他是一个概念机上的机器语言,不是在一个真正存在的物理机上运行的机器语言。正因如此,WebAssem...

2021-02-24 23:01:52 1141

原创 gRPC nodejs踩坑

用nodejs写的gRPC流式服务端,在循环体外部创建了proto消息体,在循环内部set值,并write回客户端,结果客户端收到的每个包内容都相同。看到这结果,也能猜到个大概了,必定和node的异步机制有关,循环结束后才真正调用之前的write函数,导致每次发送的都是最终的proto消息。想起node闭包的一个禁忌:不要在闭包中使用外部的循环变量或后续会发生变化的变量...

2020-02-21 00:23:53 1274

原创 Java类转fastjson字符串踩坑笔记

今天,在使用fastjson时,发现Java类中的个别属性无法转换为json字符串的字段,如类Student中的studentName会被过滤掉:public class Student { private String studentName; public String getName() { return studentName; } ...

2019-11-06 00:25:19 279

原创 Java与C++对比学习

c++ string类的substr()方法中的第二个参数为长度;Java String类的substring()方法中的第二个参数为不包括的结束位置;python中的字符串由 [start : end] 获得,两个参数含义和java一致;java中不能直接修改字符串的值,只能通过其他操作的组合实现。c++ compare()函数功能比java equals()丰富。...

2019-10-20 16:35:26 481

原创 3Sum【三个数和为0】

PROBLEM:Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note:The solution set mus...

2018-10-07 11:53:25 350

原创 关于约瑟夫环问题的理解

有序列:0,1,2,3......,n-1(可以将0~n-1的序列值理解为任意数组下标),每次删除第m个,注意该序列首尾相连,即n-1的下一个为0,问最后剩下的数字是多少?此问题被称为约瑟夫环问题,可以用枚举找规律解决,但也可以使用动态规划来思考:1、记1~n-1序列最后剩下的数字为 f(n,m) ,其中n表示有n个数字,m表示每次删除第m个,因为这两个变量就能决定最后剩下的数字,所以以它...

2018-08-07 23:57:08 318

转载 进程和线程的区别

在理解进程和线程概念之前首选要对并发有一定的感性认识,如果服务器同一时间内只能服务于一个客户端,其他客户端都再那里傻等的话,可见其性能的低下估计会被客户骂出翔来,因此并发编程应运而生,并发是网络编程中必须考虑的问题。实现并发的方式有多种:比如多进程、多线程、IO多路复用。多进程进程是资源(CPU、内存等)分配的基本单位,它是程序执行时的一个实例。程序运行时系统就会创建一个进程,并为它分配资...

2018-07-22 15:40:07 172

转载 Palindrome Number【判断一个数是不是回文】

PROBLEM:Determine whether an integer is a palindrome. Do this without extra space.SOLVE(C++):class Solution {public: bool isPalindrome(int x) { if(x<0||(x%10==0&&x!=0)) ...

2018-07-11 22:21:23 403

转载 10 分钟了解 Actor 模型

过去十几年CPU一直遵循着摩尔定律发展,单核频率越来越快,但是最近这几年,摩尔定律已然失效,CPU的工艺制程和发热稳定性之间难以取舍,取而代之的策略则是增加核心数量,目前家用电脑四核已经非常常见,服务器更是达到了32核64线程。为了有效地利用多核CPU,我们在代码层面就应该考虑到并发性。十几年的痛苦开发经历告诉我们,threads并不是获取并发性的好方法,往往会带来难以查找的bug,但是不用害怕,...

2018-07-09 08:39:44 415

原创 KMP算法代码

本文主要是方便自己查找记忆,先贴代码:#include <string>#include <vector>#include <iostream>using namespace std;vector<int> GetNextval(string p) { // 由模式字符串p返回next数组 int pLen = p.size(); v...

2018-07-04 23:05:12 679

原创 【 C/C++ & Python】随机数产生

C++中有两种方式:第一种方式是使用<cstdlib>中的rand()函数,这是ANSI C标准,在gcc/g++编译器中也直接可用;第二种方式是使用<random>库文件,下面对这两种方法进行介绍:1、<cstdlib> & rand()rand() 函数在头文件<cstdlib> 中,产生的随机数为无符号整数,在0~RAND_MAX 之间...

2018-06-30 20:24:34 1258

原创 Convert BST to Greater Tree【将二叉树转换】

PROBLEM:Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all keys greater than the original key in BST....

2018-06-17 10:42:27 221

原创 【Python】琐碎知识点整理记录

1、sorted( )[: :-1] 排序完了直接逆序切片;map(function, list) 将第一个方法作用于后一个数组上的所有元素;python3中map函数直接返回map对象(python2则是返回list);dict( ) 直接将zip包转换为内置字典类型,dict中的get方法返回key对应的值(如果存在,否则返回定义的值或者none)如下代码:sort=sorted(nums)[...

2018-06-15 18:09:48 342

原创 Find Mode in Binary Search Tree【找到BST树中出现最多的元素】

PROBLEM:Given a binary search tree (BST) with duplicates, find all the mode(s) (the most frequently occurred element) in the given BST.Assume a BST is defined as follows:The left subtree of a no...

2018-06-14 15:53:34 280

原创 Next Greater Element I【第一个数组中数字在第二个数组中找次大值】

PROBLEM:You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nums1's elements in the corresponding places of ...

2018-06-13 22:47:10 261

原创 Number Complement【求反码】

PROBLEM:Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation.Note:The given integer is guaranteed to fit within the range of...

2018-06-08 10:36:58 173

原创 Repeated Substring Pattern【重复的子字符串【KMP】】

PROBLEM:Given a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. You may assume the given string consists of lowerca...

2018-06-06 00:42:27 360

原创 Find All Numbers Disappeared in an Array【找到数组中未出现的元素】

PROBLEM:Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements of [1, n] inclusive that do not appear in this array....

2018-05-25 16:22:51 194

原创 * Path Sum III【任意 起始点—终点 路径和】

PROBLEM:You are given a binary tree in which each node contains an integer value.Find the number of paths that sum to a given value.The path does not need to start or end at the root or a leaf, but it...

2018-05-23 13:19:54 373

原创 Binary Watch【二进制手表时间转换为普通时间】

PROBLEM:A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom represent the minutes (0-59).Each LED represents a zero or one, with the least significant b...

2018-05-20 18:26:57 938

原创 【C++】string对象的大小写转换

C++中string对象可以使用 algorithm 头文件中的 transform 函数和进行大小写转换。string tmp = "Test";string tmpLower;transform(tmp.begin(), tmp.end(), back_inserter(tmpLower), ::tolower);其中back_inserter( ) 是在头文件 iterator 中定义...

2018-05-20 00:06:44 1292

原创 Nth Digit【第n个数字】

PROBLEM:Find the nth digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...Note:n is positive and will fit within the range of a 32-bit signed integer (n < 231).Example 1:Inp...

2018-05-10 11:14:52 261

原创 Rotate String【判断一个字符串是否为另一个字符串的偏转】

PROBLEM:We are given two strings, A and B.A shift on A consists of taking string A and moving the leftmost character to the rightmost position. For example, if A = 'abcde', then it will be 'bcdea' aft...

2018-05-09 13:11:53 268

原创 Two Sum IV - Input is a BST【二叉搜索树中是否存在 “和==目标值” 的一对节点】

PROBLEM:Given a Binary Search Tree and a target number, return true if there exist two elements in the BST such that their sum is equal to the given target.Example 1:Input: 5 / \ 3 6 / \ ...

2018-05-06 13:33:23 415

原创 Non-decreasing Array【非递减数列】

PROBLEM:Given an array with n integers, your task is to check if it could become non-decreasing by modifying at most 1 element.We define an array is non-decreasing if array[i] <= array[i + 1] holds...

2018-05-05 10:48:35 340

原创 WIN10主机Ubuntu18.04 nat模式设置静态ip地址

花了一上午,一把辛酸泪,遂记录以备不时之需及供网友参考虚拟机VMware Workstation Pro安装及ubuntu系统安装此处不做介绍,我的Ubuntu是用的最简安装,且网络连接模式按默认的选择nat模式,一切就绪后就开始进行静态ip地址修改了。有问题欢迎留言~-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-正文分割线-*-*-*-*-*-*-*-*-*-...

2018-05-04 14:44:09 7679 4

原创 【OS】操作系统琐碎知识点整理

1、CS:段指针,IP:偏移指针;一个扇区有512字节。X86计算机启动时,cpu首先处于实模式;开机时,CS=0xFFFF,IP=0x0000,寻址0Xffff0(ROM BIOS映射区),这个区程序检查键盘显示器硬盘等硬件;接着将磁盘0磁道0扇区读入0x7C00处,此时设置CS=0x07C0,IP=0x0000。2、操作系统工作步骤:计算机工作原理是取址执行。一开始操作系统是在磁盘上,需要将其...

2018-05-03 09:44:59 312

原创 Second Minimum Node In a Binary Tree【特定数中第二小的数】

PROBLEM:Given a non-empty special binary tree consisting of nodes with the non-negative value, where each node in this tree has exactly two or zero sub-node. If the node has two sub-nodes, then this n...

2018-05-02 18:55:49 179

原创 Sum of Two Integers【不用+ -,算加法】

PROBLEM:Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -.SOLVE:class Solution {public: int getSum(int a, int b) { long long sum=a; ...

2018-04-29 22:46:02 240

原创 【C++】关于 std::set_intersection( ) 函数用法

C++ STL 提供求交集的函数 set_intersection( ) 、求集合差的函数set_difference( ) 和合并两个集合的函数 set_union( ) 。以set_intersection( ) 为例,分析两端程序并简单记录其用法:nums1:1,2,2,1nums2:2,2#include <algorithm> // set_inter...

2018-04-22 22:00:47 29778

原创 Intersection of Two Arrays【合并两个set】

PROBLEM:Given two arrays, write a function to compute their intersection.Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2].Note:Each element in the result must be unique.The result can be...

2018-04-22 20:52:03 183

原创 Repeated String Match【重复字符串匹配】

PROBLEM:Given two strings A and B, find the minimum number of times A has to be repeated such that B is a substring of it. If no such solution, return -1.For example, with A = "abcd" and B = "cdabcdab...

2018-04-18 23:38:04 332

原创 Word Pattern【熟练map容器】

PROBLEM:Given a pattern and a string str, find if str follows the same pattern.Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in str.Ex...

2018-04-15 15:05:45 208

原创 Power of Three【判断一个数是否为3的幂】

PROBLEM:Given an integer, write a function to determine if it is a power of three.Follow up:Could you do it without using any loop / recursion?SOLVE:class Solution {public: bool isPowerOfThree(in...

2018-04-14 20:52:32 924

原创 Longest Univalue Path【数的最长路径】

PROBLEM:Given a binary tree, find the length of the longest path where each node in the path has the same value. This path may or may not pass through the root.Note: The length of path between two nod...

2018-04-11 15:37:36 295

原创 【汇编】看基础课程知识点记录

学习每个指令注意其指令执行原理,尝试用其他组合指令去替代有利于理解,不要只停留于指令语法!1、每个应用程序都会有自己的独立的4GB内存空间,汇编中通常说的内存正是这进程对应的内存,而不是物理内存或内存条。2、32位机上的一块内存的寻址宽度为 0x00000000~0xFFFFFFFF,其中每 0x1中有8 bit,所以这个值正好对应4G内存空间。3、汇编中 movs 可以将一段内存赋值给另一段内存...

2018-04-09 22:55:50 180

转载 【C++】Visual定位内存泄漏方法

原博客地址:https://blog.csdn.net/sinat_20265495/article/details/51763084方法一:#ifdef _DEBUG #define New new(_NORMAL_BLOCK, __FILE__, __LINE__) #endif #define CRTDBG_MAP_ALLOC #include &lt;stdl...

2018-04-07 02:15:17 255

原创 【C++】实现JAVA中的split方法

JAVA中的split函数可谓相当好用,可惜我没在C++中找到类似方法...于是乎我在网上找到了两种自己实现的函数,简单介绍下,之后进行简单比较讨论:常规方法:vector&lt;string&gt; split(string str){ int start=0, end=0, size=str.size(); vector&lt;string&gt; result; ...

2018-04-05 20:15:37 463

原创 Second Highest Salary

PROBLEM:Write a SQL query to get the second highest salary from the Employee table.+----+--------+| Id | Salary |+----+--------+| 1 | 100 || 2 | 200 || 3 | 300 |+----+--------+For e...

2018-03-20 22:15:03 171

原创 Add Digits

PROBLEM:Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one...

2018-03-20 00:59:15 160

空空如也

空空如也

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

TA关注的人

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