IDEA快捷键
clion常用快捷键:
command + [ 回退
command + ] 前进
command + O 查找class
shift command + O 查找文件
option command + O 查找符号
clion常用快捷键:
command + [ 回退
command + ] 前进
command + O 查找class
shift command + O 查找文件
option command + O 查找符号
1.在网站 https://www.ipaddress.com/ 上搜索
github.global.ssl.fastly.net
github.com
这两个域名所对应的ip填入/etc/hosts中
2.添加hosts
[root grpc]#cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.loc......
堆盘子。设想有一堆盘子,堆太高可能会倒下来。因此,在现实生活中,盘子堆到一定高度时,我们就会另外堆一堆盘子。请实现数据结构SetOfStacks,模拟这种行为。SetOfStacks应该由多个栈组成,并且在前一个栈填满时新建一个栈。此外,SetOfStacks.push()和SetOfStacks.pop()应该与普通栈的操作方法相同(也就是说,pop()返回的值,应该跟只有一个栈时的情况一样)。 进阶:实现一个popAt(int index)方法,根据指定的子栈,执行pop操作。
当某个栈为空时,应当删除该栈。当栈中没有元素或不存在该栈时,pop,popAt 应返回 -1.
示例1......
递归乘法。 写一个递归函数,不使用 * 运算符, 实现两个正整数的相乘。可以使用加号、减号、位移,但要吝啬一些。
由于题目要求使用递归函数实现,方法一:
class Solution {
public:
int multiply(int A, int B) {
if(A == 0 || B == 0)
return 0;
if(A < B)
return B + multiply(A-1,B);
else
return A + multiply(A, B-1);
}
};
之所以要判断A与B的大小,是因为使用小的作为循环次数,可以提高效率。
方法二:分治法
clas......
启动redis
[root ~]#redis-server
8988:C 25 Jun 11:24:31.317 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
8988:M 25 Jun 11:24:31.319 * Increased maximum number of open files to 10032 (it was originally set to 1024).......
class Solution {
public:
int firstMissingPositive(vector<int>& nums) {
int n = nums.size();
for(int i = 0;i < n;i++)
{
if(nums[i] <= 0)
nums[i] = n + 1;
}
for (int i = 0; i < n; ++i) {
int num = abs(nums[i]);
if (num <= n) {
nums[num - 1] = -abs(nums[num - 1]);
}
}
for(int i......
class Solution {
public:
int compareVersion(string version1, string version2) {
istringstream v1(version1);
istringstream v2(version2);
while(!v1.eof() || !v2.eof())
{
string s1 = "0",s2 = "0";
if(!v1.eof())
getline(v1,s1,'.');
if(!v2.eof())
getline(v2,s2,'.');
int n1 = atoi(s1.c_str());
int n2 =......
class Solution {
public:
int divide(int dividend, int divisor) {
if(dividend == INT_MIN && divisor == -1) return INT_MAX;
long long A = llabs(dividend),B = llabs(divisor),ans = 0;
while(A >= B)
{
long long base = B,m = 1;
while(base << 1 <= A)
{
base <<= 1;
m <<= 1;
......
冒泡排序
class Solution {
public:
vector<int> sortArray(vector<int>& nums) {
for(int i = nums.size()-1;i > 0;i--)
{
for(int j = 0;j < i;j++)
if(nums[j] > nums[j+1])
swap(nums[j],nums[j+1]);
}
return nums;
}
};
执行结果:
Time Limit Exceeded
Details
Last executed input
[5864,-1......
#include <semaphore.h>
class Foo {
protected:
sem_t firstJobDone;
sem_t secondJobDone;
public:
Foo() {
sem_init(&firstJobDone, 0, 0);
sem_init(&secondJobDone, 0, 0);
}
void first(function<void()> printFirst) {
// printFirst() outputs "first". Do not change or remove th......