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周了还是晚上睡不好,老饿
睡觉做梦我就没办法了,饿的话就少吃多餐
相关阅读
求推荐 纽约曼哈顿区 妇产 医生以及医院请大家点评/分享8个月大娃奶和辅食的schedule求JMS推荐几个好的南湾的daycare吧终于孕了,兴奋又紧张,有好些问题想请教大家崩溃求助---35天小娃的poo问题娃不愿意穿diaper了,怎么办宝宝不会自己抓东西吃,怎么办?宝宝衣服sale! (转载)吃antibiotics多久才能恢复胸喂 (updated)七个月大的宝宝再次送点冻母乳 (zip 20878)奔肉球妹床照种种。。。版上有请midwife到家里来助产的mm吗?明天37周 induce,求灵验的宝宝版祝福红色塑料袋--小宝跳舞小红花的替代品大家都是多大给孩子吃块状食物的?宝宝上海上户口求祝福!Moving sale----good condition toys -(NY Armonk 10504)真诚求建议