t*t
2 楼
Given an array S of n integers, are there elements a, b, c in S such that a
+ b + c = 0? Find all unique triplets in the array which gives the sum of
zero.
Note:
Elements in a triplet (a,b,c) must be in non-descending order. (ie, a ≤ b
≤ c)
The solution set must not contain duplicate triplets.
For example, given array S = {-1 0 1 2 -1 -4},
A solution set is:
(-1, 0, 1)
(-1, -1, 2)
class Solution {
private:
int increment(vector& nums, int l, int r){
while(l return l;
}
int decrement(vector& nums, int l, int r){
while(r>l && nums[r]==nums[--r]){}
return r;
}
public:
vector> threeSum(vector& nums) {
vector> res;
if(nums.size()<3) return res;
sort(nums.begin(), nums.end());
for(int i=0; i int l = i+1;
int r = nums.size()-1;
while(l if(nums[i]+nums[l]+nums[r] == 0){
vector tmp {nums[i], nums[l], nums[r]};
res.push_back(tmp);
l = this->increment(nums,l,r);
r = this->decrement(nums,l,r);
}
else if(nums[i]+nums[l]+nums[r] < 0){
l = this->increment(nums,l,r);
}
else{
r = this->decrement(nums,l,r);
}
}
}
return res;
}
};
+ b + c = 0? Find all unique triplets in the array which gives the sum of
zero.
Note:
Elements in a triplet (a,b,c) must be in non-descending order. (ie, a ≤ b
≤ c)
The solution set must not contain duplicate triplets.
For example, given array S = {-1 0 1 2 -1 -4},
A solution set is:
(-1, 0, 1)
(-1, -1, 2)
class Solution {
private:
int increment(vector
while(l
}
int decrement(vector
while(r>l && nums[r]==nums[--r]){}
return r;
}
public:
vector
vector
if(nums.size()<3) return res;
sort(nums.begin(), nums.end());
for(int i=0; i
int r = nums.size()-1;
while(l
vector
res.push_back(tmp);
l = this->increment(nums,l,r);
r = this->decrement(nums,l,r);
}
else if(nums[i]+nums[l]+nums[r] < 0){
l = this->increment(nums,l,r);
}
else{
r = this->decrement(nums,l,r);
}
}
}
return res;
}
};
x*z
3 楼
其实好像前些天还看到了有mm发帖子的。 我的经期不准,现在也不知道几周了,我估
计也就3,4周。现在就是每天晚上睡的很不好!!很热,会出汗,热醒。还做各种梦,
反正不是美梦。吃东西不太多,但很容易饿。真怕这样不正常,jms有谁有过这样的经
历吗?
计也就3,4周。现在就是每天晚上睡的很不好!!很热,会出汗,热醒。还做各种梦,
反正不是美梦。吃东西不太多,但很容易饿。真怕这样不正常,jms有谁有过这样的经
历吗?
u*l
4 楼
class Solution {
public:
vector> threeSum(vector& nums) {
vector> ret;
if (nums.size() < 3) {
return ret;
}
sort(nums.begin(), nums.end());
for (int i = 0; i < nums.size() - 2; ++i) {
if (i > 0 && nums.at(i) == nums.at(i - 1)) {
continue;
}
twoSum(ret, i + 1, nums, 0 - nums.at(i));
}
return ret;
}
private:
void twoSum(vector>& res, int index, vector& sortedNums
, int target) {
int head = index;
int tail = sortedNums.size() - 1;
while (head < tail) {
int tmp = sortedNums.at(head) + sortedNums.at(tail);
if (tmp < target) {
++head;
}
else if (tmp > target) {
--tail;
}
else {
vector v;
v.push_back(sortedNums.at(index - 1));
v.push_back(sortedNums.at(head));
v.push_back(sortedNums.at(tail));
res.push_back(v);
int k = head + 1;
while (k < tail && sortedNums.at(k) == sortedNums.at(head)) {
++k;
}
head = k;
k = tail - 1;
while (k > head && sortedNums.at(k) == sortedNums.at(tail)) {
--k;
}
tail = k;
}
}
}
};
public:
vector
vector
if (nums.size() < 3) {
return ret;
}
sort(nums.begin(), nums.end());
for (int i = 0; i < nums.size() - 2; ++i) {
if (i > 0 && nums.at(i) == nums.at(i - 1)) {
continue;
}
twoSum(ret, i + 1, nums, 0 - nums.at(i));
}
return ret;
}
private:
void twoSum(vector
, int target) {
int head = index;
int tail = sortedNums.size() - 1;
while (head < tail) {
int tmp = sortedNums.at(head) + sortedNums.at(tail);
if (tmp < target) {
++head;
}
else if (tmp > target) {
--tail;
}
else {
vector
v.push_back(sortedNums.at(index - 1));
v.push_back(sortedNums.at(head));
v.push_back(sortedNums.at(tail));
res.push_back(v);
int k = head + 1;
while (k < tail && sortedNums.at(k) == sortedNums.at(head)) {
++k;
}
head = k;
k = tail - 1;
while (k > head && sortedNums.at(k) == sortedNums.at(tail)) {
--k;
}
tail = k;
}
}
}
};
c*e
5 楼
这个还算不上早孕反应吧。上次月经什么时候?用试纸测过吗?
如果经期不准,可以根据B超估算预产期
如果经期不准,可以根据B超估算预产期
t*t
6 楼
感谢啊,这年头,越来越难啊
v*1
11 楼
正常的反应
s*s
17 楼
我怀孕的时候就是饿的特别快,你这反应没有什么不正常的
h*m
18 楼
挺正常的。
我从知道怀孕到现在16周了还是晚上睡不好,老饿
睡觉做梦我就没办法了,饿的话就少吃多餐
我从知道怀孕到现在16周了还是晚上睡不好,老饿
睡觉做梦我就没办法了,饿的话就少吃多餐
相关阅读
Enfagrow 奶票换Similac 奶票宝宝睡觉手是冷的,求建议!pizza是有助于下奶么?从生物学角度讲,一个人的性格是天生的还是后天塑造的? (转载)Reflux需要药物治疗还是宝宝自己会好?孕17周,这是胎动还是宫缩C-Section 还是自然生?想问一下这里的妈妈们, 那种加在床边的护栏叫什么?哪里可以买到?新妈妈来请教泵奶的频率奔双宝求祝福啦请问给2,3岁小孩买个什么东西比较好morning star晨星幼儿园好不好帮朋友问个怀孕的事情十个月的娃每晚醒5-6次,怎么办?Cereal 发现蜘蛛网哇塞,第一次在金家买到白菜S家一段在上海有mm需要吗?给美妈们推荐一个给宝宝做食物的好方法版上的准妈妈们如果以前的filling掉了是看牙医还是等生了以后Baby shower就是国内的满月酒吗?