- 博客(694)
- 收藏
- 关注
原创 WebAssembly简易demo
Given the root of a binary tree, check whether it is a mirror of itself (i.e., symmetric around its center).Example 1:Input: root = [1,2,2,3,4,4,3]Output: trueExample 2:Input: root = [1,2,2,null,3,null,3]Output: falseConstraints:The number of
2021-03-12 19:44:15 481
原创 26. Remove Duplicates from Sorted Array
Given a sorted array nums, remove the duplicates in-place such that each element appears only once and returns the new length.Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.Cla
2021-02-20 14:59:47 322
原创 Electron打开开发者工具devtools快捷键
window是 shift + ctrl + imac是shift + cmd + i
2021-01-25 14:09:04 3715 3
原创 Git 常用命令
# 查看工作区和暂存区的状态$ git status # 将工作区的文件提交到暂存区$ git add . # 提交到本地仓库$ git commit -m "本次提交说明"# add和commit的合并,便捷写法(未追踪的文件无法直接提交到暂存区/本地仓库)$ git commit -am "本次提交说明" # 将本地分支和远程分支进行关联$ git push -u origin branchName # 将本地仓库的文件推送到远程分支$ git push# 拉取远程分支的代码
2021-01-22 11:22:57 197
原创 electron只运行单个实例
在主进程中添加const gotTheLock = app.requestSingleInstanceLock()if (!gotTheLock) { app.quit()} { app.on('second-instance', (event, argv) => { if (process.platform === 'win32') { if (win) { if (win.isMinimized()) { win.restore
2021-01-21 15:39:33 978
原创 JS监听DOM位置移动
const config = { attributes: true, childList: true, subtree: true };const callback = (mutationsList, observer) => { let getBoundingClientRect = this.getBoundingClientRect() console.log('postion', `left: ${getBoundingClientRect.left}`, `bottom:
2021-01-21 15:37:31 4364
原创 JS监听DOM元素resize
try { let resizeObserver = new ResizeObserver(entries => { console.log('resize', entries) }) resizeObserver.observe(this)} catch (e) { console.log(e)}
2021-01-21 10:19:43 1312
原创 JavaScript判断数组是否包含某元素
find()与findIndex()方法let arr = [1, 2, undefined, '听风是风', 'echo']; //利用indexOf查找下标的特性let result = arr.find(ele => ele === '听风是风')//听风之风if (result) { //do something...};find方法是比较推荐的做法,find方法会找到第一个符合条件的数组元素,并返回它,如果没找到则返回undefined。需要注意的是,只要find找.
2021-01-20 15:03:13 707
原创 webgl里的变量
attribute: 用在顶点着色器中接收顶点相关信息uniform: 可以同时在顶点着色器和片元着色器中使用,接收无顶点无关的数据varying 同时在顶点着色器和片元着色器中定义,用于在两者之间传递数据...
2021-01-20 10:40:19 180
原创 C++中的iterator->second
std::map<X, Y>实际储存了一串std::pair<const X, Y>std::map<std::string, int> m = /* fill it */;auto it = m.begin();这里,如果你用*it,那么你将得到map第一个元素的std::pair:现在你可以接收std::pair的两个元素:(*it).first会得到key(*it).second会得到value这等同于it->first和it->seco
2021-01-12 14:04:52 907
原创 C++中erase的用法
erase(pos,n);删除从下标pos开始的n个字符,比如erase(0,1)就是删除第一个字符erase(position);删除postion处的一个字符(position是一个string类型的迭代器)erase(first,last)删除从first到last之间的字符(first和last都是迭代器)...
2021-01-12 14:01:19 614
原创 172. Factorial Trailing Zeroes
Given an integer n, return the number of trailing zeroes in n!.Example 1:Input: 3Output: 0Explanation: 3! = 6, no trailing zero.Example 2:Input: 5Output: 1Explanation: 5! = 120, one trailing zero.public class Solution { public int trailin
2020-08-01 16:13:37 139
原创 153. Find Minimum in Rotated Sorted Array
Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]).Find the minimum element.You may assume no duplicate exists in the array.Example 1:Input: [3,4,5,1,2]
2020-08-01 15:11:48 134
原创 js实现复制功能
var oInput = document.getElementById('input');oInput.select(); // 选择对象document.execCommand("Copy"); // 执行浏览器复制命令message.success("复制成功", 1);var dummy = document.createElement('input');text = window.location.href;document.body.appendChild(dummy);dumm
2020-06-20 16:30:34 300
原创 在 64 位系统下安装 32 位 electron
直接 npm 安装npm install --arch=ia32 electron@1.4.14配置 .npmrcarch=ia32registry=https://registry.npm.taobao.org配置 package.json{ "config": { "arch": "ia32", "registry": "https://regi...
2020-02-27 15:36:05 1581
原创 1331. Rank Transform of an Array
Given an array of integers arr, replace each element with its rank.The rank represents how large the element is. The rank has the following rules:Rank is an integer starting from 1.The larger the e...
2020-02-05 23:01:52 288
原创 1160. Find Words That Can Be Formed by Characters
You are given an array of strings words and a string chars.A string is good if it can be formed by characters from chars (each character can only be used once).Return the sum of lengths of all good ...
2020-02-05 22:03:46 245
原创 JS常用函数
const _max = Math.max.bind(Math);const _min = Math.min.bind(Math);const _pow = Math.pow.bind(Math);const _floor = Math.floor.bind(Math);const _round = Math.round.bind(Math);const _ceil = Math.cei...
2020-02-03 15:39:05 269 1
原创 884. Uncommon Words from Two Sentences
We are given two sentences A and B. (A sentence is a string of space separated words. Each word consists only of lowercase letters.)A word is uncommon if it appears exactly once in one of the sente...
2020-02-02 20:06:09 217
原创 149. Max Points on a Line
Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.Example 1:Input: [[1,1],[2,2],[3,3]]Output: 3Explanation:^|| o| o| o +--------...
2020-01-30 16:25:11 123
原创 Promise实现原理
// 判断变量否为function const isFunction = variable => typeof variable === 'function' // 定义Promise的三种状态常量 const PENDING = 'PENDING' const FULFILLED = 'FULFILLED' const REJECTED = 'REJECTED'...
2020-01-19 10:28:52 165
原创 232. Implement Queue using Stacks
Implement the following operations of a queue using stacks.push(x) – Push element x to the back of queue.pop() – Removes the element from in front of queue.peek() – Get the front element.empty() ...
2020-01-18 16:05:09 104
原创 208. Implement Trie (Prefix Tree)
Implement a trie with insert, search, and startsWith methods.Example:Trie trie = new Trie();trie.insert("apple");trie.search("apple"); // returns truetrie.search("app"); // returns falset...
2020-01-12 16:38:41 143
原创 137. Single Number II
Given a non-empty array of integers, every element appears three times except for one, which appears exactly once. Find that single one.Note:Your algorithm should have a linear runtime complexity. C...
2019-12-15 15:57:41 111
原创 python删除指定文件
#! python 3# -*- coding:utf-8 -*-'''Copy指定格式的文件到新文件夹'''import shutil,os,send2trash#定义函数,接收传入的值def SFileToDFile(sourcefile,fileclass,destinationfile): #遍历目录和子目录 for filenames in os.listd...
2019-11-26 15:21:47 681
原创 python将指定目录下的指定格式文件复制到目标目录下
#! python 3# -*- coding:utf-8 -*-# Autor: Li Rong Yang'''Copy指定格式的文件到新文件夹'''import shutil,os#定义函数,接收传入的值def SFileToDFile(sourcefile,fileclass,destinationfile): #遍历目录和子目录 for filenames ...
2019-11-26 15:20:04 722
原创 103. Binary Tree Zigzag Level Order Traversal
Given a binary tree, return the zigzag level order traversal of its nodes’ values. (ie, from left to right, then right to left for the next level and alternate between).For example:Given binary tree...
2019-11-24 14:11:02 126
原创 69. Sqrt(x)
Implement int sqrt(int x).Compute and return the square root of x, where x is guaranteed to be a non-negative integer.Since the return type is an integer, the decimal digits are truncated and only t...
2019-10-28 16:57:30 20480
原创 58. Length of Last Word
Given a string s consists of upper/lower-case alphabets and empty space characters ’ ', return the length of last word in the string.If the last word does not exist, return 0.Note: A word is defined...
2019-10-23 23:42:39 115
原创 53. Maximum Subarray
Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.Example:Input: [-2,1,-3,4,-1,2,1,-5,4],Output: 6Explanation:...
2019-10-22 22:48:59 148
原创 49. Group Anagrams
Given an array of strings, group anagrams together.Example:Input: ["eat", "tea", "tan", "ate", "nat", "bat"],Output:[ ["ate","eat","tea"], ["nat","tan"], ["bat"]]Note:All inputs will be ...
2019-10-21 23:04:49 134
原创 39. Combination Sum
Given a set of candidate numbers (candidates) (without duplicates) and a target number (target), find all unique combinations in candidates where the candidate numbers sums to target.The same repeate...
2019-10-19 21:49:34 107
原创 34. Find First and Last Position of Element in Sorted Array
Given an array of integers nums sorted in ascending order, find the starting and ending position of a given target value.Your algorithm’s runtime complexity must be in the order of O(log n).If the t...
2019-10-18 22:50:41 100
原创 Ubuntu更新VSCode
wget https://vscode-update.azurewebsites.net/latest/linux-deb-x64/stable -O /tmp/code_latest_amd64.debsudo dpkg -i /tmp/code_latest_amd64.deb
2019-10-01 22:35:08 3321 1
原创 16. 3Sum Closest
Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input would ...
2019-09-28 21:38:52 99
原创 python: NameError: name 'cmp' is not defined
python 3.4.3 的版本中已经没有cmp函数,被operator模块代替,在交互模式下使用时,需要导入模块。lt(a,b) 相当于a<b 从第一个数字或字母(ASCII)比大小 le(a,b)相当于a<=beq(a,b)相当于a==b 字母完全一样,返回True,ne(a,b)相当于a!=bgt(a,b)相当于a>bge(a,b)相当于a>...
2019-09-22 14:31:38 3888
原创 python读取文件UnicodeDecodeError: 'gbk' codec can't decode byte 0xfe in position 575056: illegal multiby
open('order.log','r', encoding='UTF-8')改为open('order.log','rb')
2019-09-22 13:50:52 435
原创 JS获取HTML插入template的DOM节点
<template id="test"></template>let indexDoc = document;let currentDoc = indexDoc.currentScript.ownerDocument;let temp = currentDoc.getElementById("test");
2019-09-21 22:45:42 1185
原创 Ubuntu系统su出现:Authentication failure的解决办法
$ sudo passwd root Enter new UNIX password://此时输入你的密码Retype new UNIX password://再次输入,相同密码。passwd: password updated successfully
2019-09-20 15:53:52 246
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人