leetcode validate binary nodes

[LeetCode] 1032. Stream of Characters

Design an algorithm that accepts a stream of characters and checks if a suffix of these characters is a string of a given array of strings words. For ......
Characters LeetCode Stream 1032 of

写一个自己用的node-cli

我们都用过 vue 的cli ,或者 react的cli, 亦或是其他的cli 如 vite 等。他们都是提供了一个全局命令,然后在终端执行这个全局命令就可以创建出模板项目。今天我们就自己做一个,给自己用的脚手架项目,帮助自己开发一些项目。 现在我们来造点需求。 背景:我们要在nextjs 项目中, ......
node-cli node cli

LeetCode——45. 跳跃游戏 II

LeetCode链接 45. 跳跃游戏 II 给定一个长度为 n 的 0 索引整数数组 nums。初始位置为 nums[0]。 每个元素 nums[i] 表示从索引 i 向前跳转的最大长度。换句话说,如果你在 nums[i] 处,你可以跳转到任意 nums[i + j] 处: 0 <= j <= n ......
LeetCode 45 II

Node12+ 下 axios 包使用报错引发的对 package.json's exports 等属性以及 esm 的探究

最近碰到一个 case,在一个用 ts 写的 node 项目里,使用 axios,本地开发没问题,但是部署上去报错了,然后使用方式改了一下就没问题了 import axios from 'axios' // 部署上去后报错 // 修改后 import axios from 'axios/dist/n ......
属性 package exports axios Node

【LeetCode动态规划#02】图解不同路径I + II(首次涉及二维dp数组,)

不同路径 力扣题目链接(opens new window) 一个机器人位于一个 m x n 网格的左上角 (起始点在下图中标记为 “Start” )。 机器人每次只能向下或者向右移动一步。机器人试图达到网格的右下角(在下图中标记为 “Finish” )。 问总共有多少条不同的路径? 示例 1: 输入 ......
数组 路径 LeetCode 动态 02

LeetCode28. 找出字符串中第一个匹配项的下标

题目描述: 给你两个字符串 haystack 和 needle ,请你在 haystack 字符串中找出 needle 字符串的第一个匹配项的下标(下标从 0 开始)。 如果 needle 不是 haystack 的一部分,则返回 -1 。 示例 1: 输入:haystack = "sadbutsa ......
下标 字符串 字符 LeetCode 28

leetcode-1480-easy

Running Sum of 1d Array Given an array nums. We define a running sum of an array as runningSum[i] = sum(nums[0]…nums[i]). Return the running sum of nu ......
leetcode 1480 easy

leetcode-1450-easy

Number of Students Doing Homework at Given Time Given two integer arrays startTime and endTime and given an integer queryTime. The ith student started ......
leetcode 1450 easy

leetcode-1437-easy

Check If All 1's Are at Least Length K Places Away Given an binary array nums and an integer k, return true if all 1's are at least k places away from ......
leetcode 1437 easy

leetcode-1317-easy

Find the Distance Value Between Two Arrays Given two integer arrays arr1 and arr2, and the integer d, return the distance value between the two arrays ......
leetcode 1317 easy

Node.js 安装配置

Linux 上安装 Node.js 直接使用已编译好的包 Node 官网已经把 linux 下载版本更改为已编译好的版本了,我们可以直接下载解压后使用: # wget https://nodejs.org/dist/v10.9.0/node-v10.9.0-linux-x64.tar.xz // 下 ......
Node js

Leetcode(剑指offer专项训练)——DP专项(2)

三角形中最小路径之和 1.题目描述 给定一个三角形 triangle ,找出自顶向下的最小路径和。 每一步只能移动到下一行中相邻的结点上。相邻的结点 在这里指的是 下标 与 上一层结点下标 相同或者等于 上一层结点下标 + 1 的两个结点。也就是说,如果正位于当前行的下标 i ,那么下一步可以移动到 ......
专项 Leetcode offer

Leetcode Practice -- 字符串

14. 最长公共前缀 编写一个函数来查找字符串数组中的最长公共前缀。 如果不存在公共前缀,返回空字符串 ""。 输入:strs = ["flower","flow","flight"] 输出:"fl" 思路解析 string longestCommonPrefix(vector<string>& s ......
字符串 字符 Leetcode Practice

Leetcode(剑指offer专项训练)——DP专项(1)

路径的数目 题目: 一个机器人位于一个 m x n 网格的左上角 (起始点在下图中标记为 “Start” )。 机器人每次只能向下或者向右移动一步。机器人试图达到网格的右下角(在下图中标记为 “Finish” )。 问总共有多少条不同的路径 链接 思路: 这是一道基础的DP题目,走到位置(1,1)只 ......
专项 Leetcode offer

CF EC Round 145 D. Binary String Sorting

D 题意 给一个01串,交换两个数需要花费$10^{12}$,删除某个数需要花费$10^{12}+1$,问最少花费多少使得串单调不降 思路 线性dp,$f[i][0]$表示前i位构建的串结尾为0,单调不降的花费,$f[i][1]$同理,$f[i][2]$表示前i位构建的串结尾1的个数多于1的花费。 ......
Sorting Binary String Round 145

LeetCode45. 跳跃游戏 II

class Solution { public: //f[i]表示跳到i所需的最小步数 int jump(vector<int>& nums) { vector<int> f(10010,0x3f3f3f3f); int n=nums.size(); f[0]=0; for(int i=0;i<n; ......
LeetCode 45 II

LeetCode 55. 跳跃游戏

class Solution { public: //f[i]表示下标i是否能跳到 static const int N=3e4+10; bool canJump(vector<int>& nums) { int n=nums.size(); for(int i=0,j=0;i<n;i++)//j记 ......
LeetCode 55

【LeetCode动态规划#01】动规入门:求斐波那契数 + 爬楼梯(熟悉解题方法论)

斐波那契数 力扣题目链接(opens new window) 斐波那契数,通常用 F(n) 表示,形成的序列称为 斐波那契数列 。该数列由 0 和 1 开始,后面的每一项数字都是前面两项数字的和。也就是: F(0) = 0,F(1) = 1 F(n) = F(n - 1) + F(n - 2),其中 ......
方法论 楼梯 LeetCode 方法 动态

vue全家桶进阶之路3:Node.js

Node.js发布于2009年5月,由Ryan Dahl开发,是一个基于Chrome V8引擎的JavaScript运行环境,使用了一个事件驱动、非阻塞式I/O模型, 让JavaScript 运行在服务端的开发平台,它让JavaScript成为与PHP、Python、Perl、Ruby等服务端语言平 ......
全家 Node vue js

Node Sass version 8.0.0 is incompatible with ^4.0.0.

这是因为当前版本与4.0.0不兼容 卸载当前版本sass: npm uninstall node-sass 安装指定版本sass: npm install node-sass@4.14.1 参考这里 https://www.cnblogs.com/lisir-blogshare/p/15439088 ......
incompatible version Node Sass with

Prometheus通过Nginx防盗链加密node_exporter

node_exporter是Prometheus的一个扩展程序,也是通过go语言编写,同样是开箱即食,主要用来采集服务器上的数据(CPU、内存等等) 主机Prometheus可以通过部署在客户端的node_exporter拉取到数据,只需要在Prometheus.yml里面添加一个job就可以了。 ......
node_exporter Prometheus exporter Nginx node

D. Binary String Sorting

D. Binary String Sorting You are given a binary string $s$ consisting of only characters 0 and/or 1. You can perform several operations on this string ......
Sorting Binary String

LeetCode151. 反转字符串中的单词

题目描述: 给你一个字符串 s ,请你反转字符串中 单词 的顺序。 单词 是由非空格字符组成的字符串。s 中使用至少一个空格将字符串中的 单词 分隔开。 返回 单词 顺序颠倒且 单词 之间用单个空格连接的结果字符串。 注意:输入字符串 s中可能会存在前导空格、尾随空格或者单词间的多个空格。返回的结果 ......
字符串 单词 字符 LeetCode 151

LeetCode 169. 多数元素(/hash sort 随机化 分治 Boyer-Moore 投票算法)

原题解 ###题目 约束 ###题解 ####方法一:哈希表 class Solution { public: int majorityElement(vector<int>& nums) { unordered_map<int, int> counts; int majority = 0, cnt ......
算法 Boyer-Moore LeetCode 元素 Boyer

116Cebtos7安装node

在windows中本来安装了node,就自带npm 但是在centos7中,安装了node 没有npm这个命令 于是就有了这个... 首先安装node yum install epel-release yum install nodejs 再安装npm yum install npm ......
Cebtos7 Cebtos node 116

LeetCode剑指 Offer 05. 替换空格

题目描述: 请实现一个函数,把字符串 s 中的每个空格替换成"%20"。 示例 1: 输入:s = "We are happy."输出:"We%20are%20happy." 限制: 0 <= s 的长度 <= 10000 //使用一个新的对象,复制 str,复制的过程对其判断,是空格则替换,否则直 ......
空格 LeetCode Offer 05

代码随想录Day7-Leetcode454. 四数相加 II,383. 赎金信 ,15. 三数之和 ,18. 四数之和

### 454. 四数相加 II 这个第一时间没想出来怎么做的; 后面看了题解才发现可以两两分组;绝了 /** * @param {number[]} nums1 * @param {number[]} nums2 * @param {number[]} nums3 * @param {number ......

LeetCode541. 反转字符串 II

题目描述: 给定一个字符串 s 和一个整数 k,从字符串开头算起,每计数至 2k 个字符,就反转这 2k 字符中的前 k 个字符。 如果剩余字符少于 k 个,则将剩余字符全部反转。如果剩余字符小于 2k 但大于或等于 k 个,则反转前 k 个字符,其余字符保持原样。 示例 1: 输入:s = "ab ......
字符串 字符 LeetCode 541 II

@Valid 和 @Validated 注解用法

没有使用注解验证 要求:员工的名称不能为空,且长度不能超过10个字符,那么我们以前的做法大致如下: 写完,我们启动项目测试下: (1)名称为空情况 (2)正常情况 (3)超过长度情况 可以看到,和我们料想中的一样,毫无问题。 除了名称外,我们规定年龄也是必填项,且范围在1到100岁,那么此时,我们需 ......
注解 Validated Valid

centos7 Linux 安装及升级node、npm

centos7 初始版本 node 6 npm 3 更新升级node版本 # 安装 nnpm install -g n# 查看版本n --version// v9.0.1 # 把当前系统的 Node 更新成最新的 “稳定版本” n stable # 长期支持版 n lts # 最新版 n lates ......
centos7 centos Linux node npm