1 class Solution { 2 private: 3 int maxSum = INT_MIN; 4 5 public: 6 int maxGain(TreeNode* node) { 7 if (node == nullptr) { 8 return 0; 9 } 10 11 // 递归 ...
分类:
其他好文 时间:
2021-04-01 13:30:06
阅读次数:
0
管道通信(上) (一)概述 Linux Shell 都允许重定向,而重定向使用的就是管道。例如,ps | grep vsftpd 。管道是单向的、先进先出的、无结构的、固定大小的字节流。管道是Linux由Unix那里继承过来的进程间的通信机制,它是Unix早期的一个重要通信机制。其思想是,在内存中创 ...
分类:
其他好文 时间:
2021-04-01 13:26:09
阅读次数:
0
学习了二分思想 不难想到应用它来进行幂的快速运算 首先要有一些理论基础 a4=(a2)2(上过初中的都知道吧……) 现在可以快乐的开始了 本人采用的是嵌套的方法 首先要考虑几种情况 1. 指数为1 这种情况下直接return 底数就可 2. 指数为偶数 这种情况return (底数指数/2)2 3. ...
分类:
其他好文 时间:
2021-04-01 13:20:51
阅读次数:
0
最精简版本 int check_data(int *array, int n) { while(n--) if (*array++ != 0x00) return 0; return 1; } 返回1 array数组全零,否则正常非全零。 int check_data(int *array) { w ...
分类:
编程语言 时间:
2021-04-01 13:15:24
阅读次数:
0
问题: 给定一个数组,求任意区间[left, right]的元素和。 Example 1: Input ["NumArray", "sumRange", "sumRange", "sumRange"] [[[-2, 0, 3, -5, 2, -1]], [0, 2], [2, 5], [0, 5]] ...
分类:
其他好文 时间:
2021-04-01 12:58:58
阅读次数:
0
//js /** * 函数节流 * @param func * @param wait * @returns {function(...[*]=)} */ export const throttle = (func, wait = 1500) => { let timeout; return fun ...
分类:
其他好文 时间:
2021-04-01 12:56:04
阅读次数:
0
非递归前序遍历二叉树 1 void preTraverse(const BiTree &T){ 2 //initialStack(stack) 3 BiTree stack[MAX]; 4 int top=-1; 5 BiTree p=T; 6 //while(!stackEmpty(stack)| ...
分类:
其他好文 时间:
2021-03-31 12:27:44
阅读次数:
0
export function formatInput(data: string) { console.log(data) var reg = /[^\d\.\,]/g; return data.replace(reg,'') // return data.replace(/^\,*^\D*(\d* ...
分类:
其他好文 时间:
2021-03-31 12:27:10
阅读次数:
0
LXI.CF868F Yet Another Minimization Problem 这种题一般来说只有决策单调性一种优化方法。不过,决策单调性可以有很多种应用,例如单调队列或是斜率优化。这题可以选择比较少见的分治优化。 明显,可以设$f[i][j]$表示前$i$个位置分成$j$段的最大收益。显然 ...
分类:
其他好文 时间:
2021-03-31 12:12:35
阅读次数:
0
class Solution { public static void main(String[] args) { int[] arr = new int[]{0, 1, 2, 2, 2, 3, 4, 5}; //int index = binarySearch(arr, 2); //int ind ...
分类:
其他好文 时间:
2021-03-31 11:46:55
阅读次数:
0