思路:防御式编程,在收尾都加1个0,这样方便循环 bool canPlaceFlowers(vector<int> &flowerbed, int n) { if (n == 0) return true; if (flowerbed.size() == 0) return false; flowe ...
分类:
其他好文 时间:
2021-01-05 10:57:55
阅读次数:
0
php函数名后冒号(:)+数据类型(返回值类型限制/php新特性) 在PHP7,一个新的功能,返回类型声明已被引入。返回类型声明指定的一个函数返回值的类型。 int float bool string interfaces array callable 对象实例 参考:https://www.run ...
分类:
Web程序 时间:
2021-01-04 11:18:11
阅读次数:
0
1.背景: countDownLatch是在java1.5被引入,跟它一起被引入的工具类还有CyclicBarrier、Semaphore、concurrentHashMap和BlockingQueue。 存在于java.util.cucurrent包下。 2.概念 countDownLatch这个 ...
分类:
其他好文 时间:
2021-01-04 11:15:53
阅读次数:
0
比如2020年12月31日,是2020年的第366天。那么如何计算这个第几天呢? 首先当然是小学常识,给定的年份不是平年(一年365天),就是闰年(一年366天),平年1月到12月,每月分别有31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31天,闰年2月比平 ...
分类:
编程语言 时间:
2021-01-04 11:13:21
阅读次数:
0
给定一个整数n,将数字1~n排成一排,将会有很多种排列方法。 现在,请你按照字典序将所有的排列方法输出。 #include<bits/stdc++.h> using namespace std; int n,p[10]; bool k[10]; void out() { for(int i=1;i< ...
?一些录友表示跟不上现在的节奏,想从头开始打卡学习起来,可以在公众号左下方,「算法汇总」可以找到历史文章,都是按系列排好顺序的,挨个看就可以了,看文章下的留言你就会发现,有很多录友都在从头打卡,你并不孤单!?93.复原IP地址题目地址:https://leetcode-cn.com/problems/restore-ip-addresses/给定一个只包含数字的字符串,复原它并返回所有可能的IP地
分类:
编程语言 时间:
2021-01-02 10:59:47
阅读次数:
0
整数域上的二分 模板样式 bool check(int x) {/* ... */} // 检查x是否满足某种性质 // 区间[l, r]被划分成[l, mid]和[mid + 1, r]时使用: int bsearch_1(int l, int r) { while (l < r) { int m ...
分类:
其他好文 时间:
2021-01-01 12:14:33
阅读次数:
0
可以使用 typeof 操作符来检测变量的数据类型。 typeof "John" // 返回 stringtypeof 3.14 // 返回 numbertypeof false // 返回 booleantypeof [1,2,3,4] // 返回 objecttypeof {name:'John ...
分类:
其他好文 时间:
2020-12-30 10:48:20
阅读次数:
0
int GetResourceId(void) { typedef BOOL (*P_IsWow64Process)(HANDLE, BOOL *); HMODULE kernel32 = LoadLibrary(L"kernel32.dll"); P_IsWow64Process __sys_Is ...
分类:
系统相关 时间:
2020-12-30 10:33:55
阅读次数:
0
java中的多线程在java中要想实现多线程,有两种手段,一种是继续Thread类,另外一种是实现Runable接口。对于直接继承Thread的类来说,代码大致框架是:class类名extendsThread{方法1;方法2;…publicvoidrun(){//othercode…}属性1;属性2;…}先看一个简单的例子:/***@authorRollen-Holt继承Thread类,直接调用r
分类:
编程语言 时间:
2020-12-29 11:06:18
阅读次数:
0