2.5万

666--

jxj777
ice-bear

1234abcd
Mr.K_8

Aurora...
Konggee.
ING__

class Solution {
public:
vector<int> multiply(const vector<int>& A) {
if (A.size() == 1) return {1};
vector<int> l, r(A.size(), 0), v;
for (int i = 0; i < A.size(); i ++) l.push_back(i == 0 ? A[i] : l[i - 1] * A[i]);
for (int i = A.size() - 1; i >= 0; i --) r[i] = (i == A.size() - 1 ? A[i] : r[i + 1] * A[i]);
for (int i = 0; i < A.size(); i ++) {
if (i == 0) v.push_back(r[i + 1]);
else if (i == A.size() - 1) v.push_back(l[i - 1]);
else v.push_back(l[i - 1] * r[i + 1]);
}
return v;
}
};
//这里填你的代码^^
//注意代码要放在两组三个点之间，才可以正确显示代码高亮哦~


class Solution {
public:
return num1 + num2;
}
};
//这里填你的代码^^
//注意代码要放在两组三个点之间，才可以正确显示代码高亮哦~


11天前
class Solution {
public:
int maxDiff(vector<int>& nums) {
int n = nums.size(), res = 0;
vector<int> maxnum(n, 0);
for (int i = n - 1; i >= 0; i --) maxnum[i] = i == n - 1 ? nums[i] : max(maxnum[i + 1], nums[i]);
for (int i = 0; i < n - 1; i ++) res = max(res, maxnum[i + 1] - nums[i]);
return res;
}
};
//这里填你的代码^^
//注意代码要放在两组三个点之间，才可以正确显示代码高亮哦~


11天前
class Solution {
public:
int strToInt(string str) {
int pos = 1, k = 0;
while (str[k] == ' ') k ++;
if (str[k] == '+') pos = 1, k ++;
else if (str[k] == '-') pos = -1, k ++;

long long res = 0;
while (str[k] >= '0' && str[k] <= '9') {
res = res * 10 + str[k] - '0';
if (pos == 1 && res > INT32_MAX) return INT32_MAX;
else if (pos == -1 && pos * res < INT32_MIN) return INT32_MIN;
k ++;
}
return pos * res;
}
};
//这里填你的代码^^
//注意代码要放在两组三个点之间，才可以正确显示代码高亮哦~


11天前
class Solution {
public:
int getSum(int n) {
char erbi[n][n + 1];
return sizeof(erbi) >> 1;
}
};
//这里填你的代码^^
//注意代码要放在两组三个点之间，才可以正确显示代码高亮哦~


11天前
class Solution {
public:
bool isContinuous( vector<int> numbers ) {
if (numbers.size() == 0) return false;
sort(numbers.begin(), numbers.end());
int cnt = 0, j = 0;
for (int i = 0; i < 5; i ++)
if (numbers[i] == 0)
cnt ++, j ++;

int start = numbers[j];
for (int i = j + 1; i < 5; i ++) {
if (numbers[i] == start + 1) start ++;
else {
if (cnt) cnt --, start ++, i --;
else return false;
}
}

return true;
}
};
//这里填你的代码^^
//注意代码要放在两组三个点之间，才可以正确显示代码高亮哦~


11天前
class Solution {
public:
vector<int> numberOfDice(int n) {
int f[13][111];
memset(f, 0, sizeof(f));

for (int i = 1; i <= 6; i ++) f[1][i] = 1;
for (int i = 2; i <= n; i ++) {
for (int j = 0; j <= 6 * n; j ++) {
for (int k = 1; k <= 6; k ++) {
if (j > k) {
f[i][j] += f[i - 1][j - k];
}
}
}
}

vector<int> v;
for (int i = n; i <= 6 *n; i ++) v.push_back(f[n][i]);
return v;
}
};

//这里填你的代码^^
//注意代码要放在两组三个点之间，才可以正确显示代码高亮哦~


11天前
class Solution {
public:
vector<int> maxInWindows(vector<int>& nums, int k) {
vector<int> v;
int n = nums.size(), q[1010], hh = 0, tt = -1;
for (int i = 0; i < n; i ++) {
if (hh <= tt && i - q[hh] + 1 > k) hh ++;
while (hh <= tt && nums[q[tt]] <= nums[i]) tt --;
q[++ tt] = i;
if (i >= k - 1) v.push_back(nums[q[hh]]);
}
return v;
}
};
//这里填你的代码^^
//注意代码要放在两组三个点之间，才可以正确显示代码高亮哦~


11天前
class Solution {
public:
string leftRotateString(string str, int n) {
string s = str;
s += str;

string res = s.substr(n, str.size());
return res;
}
};
//这里填你的代码^^
//注意代码要放在两组三个点之间，才可以正确显示代码高亮哦~


11天前
class Solution {
public:
string reverseWords(string s) {
vector<string> v;
string tmp = "";
for (int i = 0; i < s.size(); i ++) {
if (s[i] == ' ') {
v.push_back(tmp);
tmp = "";
} else tmp += s[i];
}
v.push_back(tmp);
reverse(v.begin(), v.end());
string res = "";
for (int i = 0; i < v.size(); i ++) {
if (i == 0) res += v[i];
else {
res += " ";
res += v[i];
}
}
return res;
}
};
//这里填你的代码^^
//注意代码要放在两组三个点之间，才可以正确显示代码高亮哦~