自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

长歌倚楼的学习记录

希望自己能成为一个技术不宅

  • 博客(93)
  • 收藏
  • 关注

翻译 翻译 :深入React代码:处理状态变化

最近学习React setState的机制一直不甚理解 部门大佬推荐的文章尝试翻译一下 权当学习 有翻译的不足的地方欢迎指出原文链接点这里深入React代码:处理状态变化 状态.React命名中最复杂的概念之一。然而我们中的一些人在我们的项目中已经通过外化状态摆脱了它(Redux了解一下?),但它任旧是在react.js中被广泛使用的特性。在带来方便的同时,它可能会...

2018-08-15 02:41:10 548

原创 Git Pro Charpter 9

Git 是一套内容寻址的文件管理系统 .git 目录,几乎所有 Git 存储和操作的内容都位于该目录下。如果你要备份或复制一个库,基本上将这一目录拷贝至其他地方就可以了。 另外还有四个重要的文件或目录:HEAD 及 index 文件,objects 及 refs 目录。这些是 Git 的核心部分。objects 目录存储所有数据内容,refs 目录存储指向数据 (分支) 的提交对...

2018-08-06 11:08:43 175

原创 Each child in an array or iterator should have a unique "key" prop

1 在React 中 map this.state.array.map((el,index)=>{ return( <div>el.name</div> )})如果不给render的div 加上一个唯一的key 就会warning Each child in an array or iterator should ...

2018-08-01 14:54:00 11555

原创 Redux 与传统MVC的比较

Redux 状态管理 统一的入口与统一的状态管理 store 数据库实例 state 数据库中存贮的数据 dispatch 用户发起请求 action : { type,payload} 请求的url以及请求的数据 reducer 路由加控制器 reducer switch-case 路由 根据action.type路由到对应的控制器 reducer 对数据的操作 reduce...

2018-07-31 14:12:46 555

原创 React setState

一,React 是一个单相数据流的框架 unidirectional data flowsetState是异步的因此对于要立即更新并且使用其值的情况来说并不能得出确切的答案 官网上给出的解决方式是采用传入一个匿名函数的方式更加稳妥this.setState(function (prevState,props){ return ( counter :pr...

2018-07-30 13:24:45 135

原创 面试经验谈 OKcoin前端面试

问题 面试了Okcoin 的前端工程师 Hr很好 具体问了些深入的问题 要求明白web开发中各种背后的机制 不能只会用 要建立起完善的知识体系结构 1,Css position有哪些属性 具体解释 2,Js闭包 实际是为了访问函数内定义的数据3,React的了解程度 4,Meta标签的意义 5,Img标签中 alt title的意义 6,页面的重排和重绘 7,如何理解we...

2018-04-17 18:17:13 1343 1

原创 剑指offer 构建乘积数组

class Solution {public: vector<int> multiply(const vector<int>& A) { int length=A.size(); vector<int> B(length,1); if(length!=0) { ...

2018-04-12 19:17:43 90

原创 剑指offer 数组中重复的数字

class Solution {public: // Parameters: // numbers: an array of integers // length: the length of array numbers // duplication: (Output) the duplicated nu...

2018-04-12 18:39:07 110

原创 剑指offer 把字符串转换成整数

class Solution {public: int StrToInt(string str) { int n=str.size(),s=1; long long res=0; if(!n) return 0; if(str[0]=='-') s=-1; for(int i=(str[0]=='-'||st...

2018-04-12 18:00:26 161

原创 剑指offer 不使用加减乘除做加法

class Solution {public: int Add(int num1, int num2) { while(num2!=0) { int temp=num1^num2; num2 = (num1&num2)<<1; num1=temp; ...

2018-04-12 17:41:11 112

原创 剑指offer 求1+2+3+4+。。。+n

class Solution {public: int Sum_Solution(int n) { int result=n; result&&(result+=Sum_Solution(n-1)); return result; }};题目要求不能循环判断等关键字 所有借助&& 短路运算符...

2018-04-12 17:19:42 130

原创 剑指offer 孩子们的游戏

约瑟夫环的问题class Solution {public: int LastRemaining_Solution(int n, int m) { if(n<1||m<1) return -1; int *array= new int[n];//用数组模拟环 int i=-1,step=0,count=n; ...

2018-04-12 17:03:12 214

原创 剑指offer 扑克牌顺子

扑克问题 1 ,大小王是 0 即可看作是任意的数字 先统计0的个数 2,如果有两张一样的牌,一样的数字形成对(不是0)那就不可能是顺子 3,判断相邻两张扑克的差值 如果大于零的个数 则不可能用0补全成为顺子 01456 1与4相差2 但是只有一个0就没法补全class Solution {public: bool IsContinuous( vector<int&gt...

2018-04-12 15:39:50 94

原创 翻转单词序列

class Solution {public: void ReverseWord(string &str,int start,int end) { while(start<end) { swap(str[start++],str[end--]); } } string Reve...

2018-04-12 14:57:44 150

原创 左旋转字符串

class Solution {public: string LeftRotateString(string str, int n) { int len = str.length(); if(len==0) return ""; n=n%len; str+=str; return str.substr(n,le...

2018-04-12 11:02:22 83

原创 颜色字符串转换

链接:https://www.nowcoder.com/questionTerminal/80b08802a833419f9c4ccc6e042c1cca 来源:牛客网    var regexp=/rgb((\d+),\s*(\d+),\s*(\d+))/;     var ret=sRGB.match(re...

2018-04-12 10:56:59 399

原创 字符串的长度

function strLength(s, bUnicode255For1) { if(bUnicode255For1===true) { return s.length; }else{ var len = s.length; for(var i=0;i<s.length;i++) { ...

2018-04-09 17:01:15 406

原创 数组去重

链接:https://www.nowcoder.com/questionTerminal/0b5ae9c4a8c546f79e2547c0179bfdc2来源:牛客网   var resArr = [];   var flag = true;       &

2018-04-09 16:42:59 108

原创 根据包名 在指定空间中创建对象

function namespace(oNamespace, sPackage) { var arr = sPackage.split('.'); var res=oNamespace; for(var i=0,len=arr.length;i<len;i++) { if(arr[i] in oNamespace){ i...

2018-04-09 16:27:44 173

原创 dom节点查找

function commonParentNode(oNode1, oNode2) { for(;oNode1;oNode1=oNode1.parentNode) { if(oNode1.contains(oNode2)) { return oNode1; } }}

2018-04-09 16:06:52 169

原创 获取URL参数

function getUrlParam(sUrl, sKey) {    var param = sUrl.split('#')[0].split('?')[1];    if (sKey){//指定参数名称       &n

2018-04-09 16:01:59 187

原创 Js 封装函数 f,使 f 的 this 指向指定的对象

function bindThis(f, oTarget) { return function() { return f.apply(oTarget,arguments); }}封装函数 f,使 f 的 this 指向指定的对象

2018-04-09 15:37:48 1018

原创 剑指offer 和为S的两个数字

class Solution {public: vector<int> FindNumbersWithSum(vector<int> array,int sum) { vector<int> result; int i=0; int j=array.size()-1; while(i&lt...

2018-04-09 15:31:28 160 1

原创 剑指offer 和为S的连续正数序列

class Solution {public: vector<vector<int> > FindContinuousSequence(int sum) { vector<vector<int>> result; int hign=2,low=1; while(hign>low) ...

2018-04-09 15:17:01 70

原创 剑指offer 数组中只出现一次的数字

class Solution {public: void FindNumsAppearOnce(vector<int> data,int* num1,int *num2) { int Xor=0; for(int i=0;i<data.size();++i) { Xor^=data[i]; ...

2018-04-09 13:57:11 115

原创 剑指offer 平衡二叉树

class Solution {public: bool IsBalanced(TreeNode *root,int &depth) { if(root==NULL) { return true; } int left=0; int right=0; i...

2018-04-09 12:43:31 81

原创 剑指offer 二叉树的深度

/* struct TreeNode { int val; struct TreeNode *left; struct TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) { } };*/ class Solution { publi...

2018-04-08 10:50:34 77

原创 剑指offer 数字在排序数组中出现的次数

class Solution {public: int GetNumberOfK(vector<int> data ,int k) { int lower = getLower(data,k); int upper = getUpper(data,k); return upper - lower; } int g...

2018-04-08 10:43:59 77

原创 剑指offer 两个链表的第一个公共节点

/*struct ListNode { int val; struct ListNode *next; ListNode(int x) : val(x), next(NULL) { }};*/class Solution {public: ListNode* FindFirstCommonNode( ListNode* pHe...

2018-04-08 10:03:16 73

原创 剑指offer 数组中的逆序对

class Solution {public: long long InversePairsCore(vector<int> &data,vector<int>&copy,int start,int end) { if(start==end) { copy[start]=data[en...

2018-03-30 19:38:18 96

原创 剑指offer 第一个只出现一次的字符

class Solution {public:    int FirstNotRepeatingChar(string str) {        int len=str.length();    &nbsp

2018-03-30 18:20:13 75

原创 剑指offer 丑数

class Solution {public: int GetUglyNumber_Solution(int index) { if(index<=0) return 0; if(index==1) return 1; vector<int>k(index); k[0]=1; int t2=...

2018-03-30 16:52:54 70

原创 剑指offer 把数组排成最小的数

class Solution {public: static bool cmp(int a,int b) { string A=""; string B=""; A+=to_string(a); A+=to_string(b); B+=to_string(b); B+=to_strin...

2018-03-30 16:30:38 67

原创 剑指offer 整数中1出现的次数

class Solution {public: int NumberOf1Between1AndN_Solution(int n) { int count = 0;//1的个数   int i = 1;//当前位   int current = 0,after = 0,before = 0;&nbs...

2018-03-30 16:01:51 126

原创 剑指offer 连续子数组的最大和

class Solution {public: int FindGreatestSumOfSubArray(vector<int> array) { int result=array[0]; int max=array[0]; for(int i=1;i<array.size();i++) { ...

2018-03-30 15:13:19 72

原创 剑指offer 最小的k个数

链接:https://www.nowcoder.com/questionTerminal/6a296eb82cf844ca8539b57c23e6e9bf来源:牛客网class Solution {public:    vector<int> GetLeastNumbers_Solution(vector<int> inpu...

2018-03-27 11:54:33 150

原创 剑指offer 数组中出现次数超过一半的数字

class Solution {public:    int MoreThanHalfNum_Solution(vector<int> numbers) {        int n = numbers.size();  &

2018-03-27 11:07:22 90

原创 剑指offer 字符串的排列

class Solution {public:    vector<string> Permutation(string str) {        //可以用递归来做    &n

2018-03-27 10:53:58 123

原创 剑指offer 二叉搜索树与双向链表

/* struct TreeNode { int val; struct TreeNode *left; struct TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) { } };*/ class Solution { publi...

2018-03-27 10:16:53 74

原创 剑指offer 复杂链表的复制

/*struct RandomListNode { int label; struct RandomListNode *next, *random; RandomListNode(int x) : label(x), next(NULL), random(NULL) { }};*/class Solution {public: ...

2018-03-27 09:44:38 78

空空如也

空空如也

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

TA关注的人

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