Redian新闻
>
最近怎么没有人贴EAD
avatar
最近怎么没有人贴EAD# EB23 - 劳工卡
E*0
1
我说下我的算法,大家帮忙看看有没有问题。
#include
class Solution {
public:
void nextPermutation(vector &num) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
if (1==num.size())
return;
vector::reverse_iterator rit;
vector::reverse_iterator it1,it2;
for ( rit=num.rbegin() ; rit < num.rend(); ++rit )
{
rit++;
it1=rit;
rit--;
it2=rit;
if ((*(it2))>(*(it1)))
{
for (;it2!=num.rbegin();it2--)
if((*it1)>(*it2))
break;
it2--;
int temp=*it2;
*it2=*it1;
*it1=temp;
it1--;
sort(it1,num.end());
}
}
}
};
avatar
m*u
2
EAD批准情况如何?
到5月份了没?
avatar
E*0
3
我的基本想法是
1 2 3 4 5 6
- 从vector的最后一个开始循环,两个指针it1, it2分别指向当前循环指针和之前一个。
for example, 一开始it1指向6,it2 指向5.
- 比较这两个数
a) it1 >= it2 继续循环。这样可以保证所有在it1之后的书是逆序排列。
b) it1 < it2,把it1 to end 中第一个比it2大的数找到,和it2环位置,并且把从
it1 to end的数顺序排列。
- 直到所有的数都是逆序排列。
avatar
l*n
4
TSC已经开始批5月20多号的了。NSC可能还有4月底的没有批,5月初和中旬的很多没有
批。
avatar
E*0
5
举个例子
1 2 3 4 5 6
找出 4 6 5 3 2 1的next permutation.
it1 -> 6 it2 ->4 since 6 5 3 2 1是逆序排列。
找出 it1 to end 中第一个比4大的数5,(note:这里第一个币it2大的数,不是位置,
是大小上第一个比it2大的数)把5和4位置换一下。
5 6 4 3 2 1 在把6 to end 顺序排列。
so next permutation是 5 1 2 3 4 6。
avatar
m*u
6
我印象中TSC5月的就两三个吧
avatar
r*e
7
先说说你什么思想吧?我也刚刚写了一个,是返回bool的,好像比你的要复杂。
我的思路是从最后一位数起往前找到第一个位置i,s.t. vector[i]sort 从i+1 to end(), 然后swap vector[i] 和sort的range里第一个比
vector[i]大的。
也想先听听你的思路是什么,看看是不是更简单。

【在 E*******0 的大作中提到】
: 我说下我的算法,大家帮忙看看有没有问题。
: #include
: class Solution {
: public:
: void nextPermutation(vector &num) {
: // Start typing your C/C++ solution below
: // DO NOT write int main() function
: if (1==num.size())
: return;
: vector::reverse_iterator rit;

avatar
G*l
8
今天查到nsc PD 04/29,两张都approve了

【在 m******u 的大作中提到】
: 我印象中TSC5月的就两三个吧
avatar
N*8
9
1). 从右往左找第一个a[i-1] < a[i]的,记i-1为index1;
2). 从右往左找第一个比a[index1]大的数,记index2;
3). swap(a, index1, index2);
4). reverse(a, index+1, a.length-1)
avatar
w*1
10
EB2 -> 3
RD 5/27
FP 7/2
EAD card production primary 8/17, dependent 8/19

【在 m******u 的大作中提到】
: EAD批准情况如何?
: 到5月份了没?

avatar
r*e
11
最后一步应该是sort吧?

【在 N*****8 的大作中提到】
: 1). 从右往左找第一个a[i-1] < a[i]的,记i-1为index1;
: 2). 从右往左找第一个比a[index1]大的数,记index2;
: 3). swap(a, index1, index2);
: 4). reverse(a, index+1, a.length-1)

avatar
q*t
12
Nsc rd 4/30
EAD card production 8/19
avatar
E*0
13
我的基本想法是
1 2 3 4 5 6
- 从vector的最后一个开始循环,两个指针it1, it2分别指向当前循环指针和之前一个。
for example, 一开始it1指向6,it2 指向5.
- 比较这两个数
a) it1 >= it2 继续循环。这样可以保证所有在it1之后的书是逆序排列。
b) it1 < it2,把it1 to end 中第一个比it2大的数找到,和it2环位置,并且把从
it1 to end的数顺序排列。
- 直到所有的数都是逆序排列。

【在 r*****e 的大作中提到】
: 先说说你什么思想吧?我也刚刚写了一个,是返回bool的,好像比你的要复杂。
: 我的思路是从最后一位数起往前找到第一个位置i,s.t. vector[i]: sort 从i+1 to end(), 然后swap vector[i] 和sort的range里第一个比
: vector[i]大的。
: 也想先听听你的思路是什么,看看是不是更简单。

avatar
h*y
14
我的是6/30 receipt, 7/28就批准了 不过到现在还没收到 这个正常吗?
绿卡还是一动不动 SR两个星期了 要不要在问问?

【在 l*******n 的大作中提到】
: TSC已经开始批5月20多号的了。NSC可能还有4月底的没有批,5月初和中旬的很多没有
: 批。

avatar
E*0
15
我的思路和你一样。

【在 N*****8 的大作中提到】
: 1). 从右往左找第一个a[i-1] < a[i]的,记i-1为index1;
: 2). 从右往左找第一个比a[index1]大的数,记index2;
: 3). swap(a, index1, index2);
: 4). reverse(a, index+1, a.length-1)

avatar
D*7
16
请问版花,
我的RD 4/10 (NSC), 电话打了两次了,ONLINE SERVICE REQUEST 也做了。还是没
有消息,还有什么途径么? 谢谢。

【在 l*******n 的大作中提到】
: TSC已经开始批5月20多号的了。NSC可能还有4月底的没有批,5月初和中旬的很多没有
: 批。

avatar
N*8
17
index1+1:a.length-1本来就是一个逆序的子数组了,不用sort,reverse就是最小的子
数组组合。

【在 r*****e 的大作中提到】
: 最后一步应该是sort吧?
avatar
l*n
18
1. info pass
https://infopass.uscis.gov/
2. [email protected]
(function(){try{var s,a,i,j,r,c,l,b=document.getElementsByTagName("script");l=b[b.length-1].previousSibling;a=l.getAttribute('data-cfemail');if(a){s='';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2){c=parseInt(a.substr(j,2),16)^r;s+=String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})();
/* ]]> */
去follow up

【在 D********7 的大作中提到】
: 请问版花,
: 我的RD 4/10 (NSC), 电话打了两次了,ONLINE SERVICE REQUEST 也做了。还是没
: 有消息,还有什么途径么? 谢谢。

avatar
d*i
19
之前的遍历保证pivot后面是增序,reverse就够了。
不过这样做有个catch:做swap的时候要从右往左找。如638551。3要跟右起第一个5换
,不能跟第二个5换;不然reverse的结果错误。
从右边找这点人已经写在算法里了,我只是强调一下,呵呵

【在 r*****e 的大作中提到】
: 最后一步应该是sort吧?
avatar
t*o
20
Liza 姐, 你的收到了吧。
avatar
r*e
21
yes, you are right

【在 N*****8 的大作中提到】
: index1+1:a.length-1本来就是一个逆序的子数组了,不用sort,reverse就是最小的子
: 数组组合。

avatar
D*7
22
感谢版花回复。
FOLLOW UP 做过了。 INFO PASS 需要去附近的office吧?孩子太小,路程太远 没办法
去。~

(function(){try{var s,a,i,j,r,c,l,b=document.getElementsByTagName("script");l=b[b.length-1].previousSibling;a=l.getAttribute('data-cfemail');if(a){s='';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2){c=parseInt(a.substr(j,2),16)^r;s+=String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})();
/* ]]> */
去follow up

【在 l*******n 的大作中提到】
: 1. info pass
: https://infopass.uscis.gov/
: 2. [email protected]
: (function(){try{var s,a,i,j,r,c,l,b=document.getElementsByTagName("script");l=b[b.length-1].previousSibling;a=l.getAttribute('data-cfemail');if(a){s='';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2){c=parseInt(a.substr(j,2),16)^r;s+=String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})();
: /* ]]> */
: 去follow up

avatar
r*e
23
for 2), if use binary search, it would look nicer even though
overall complexity is not affected.

【在 N*****8 的大作中提到】
: 1). 从右往左找第一个a[i-1] < a[i]的,记i-1为index1;
: 2). 从右往左找第一个比a[index1]大的数,记index2;
: 3). swap(a, index1, index2);
: 4). reverse(a, index+1, a.length-1)

avatar
m*u
24
Just got message EAD&AP card production&post decision. 副申请人没有消息
EB2-EB3,
PD: 09/2012
RD: 05/30/2014
FP: 07/08/2014
EAD: 主申请人 08/21/2014 message received
算是困顿中的一点希望,和大家共勉!
avatar
E*0
25
// NextPermutation.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include
#include
using namespace std;
#include
bool myfunction (int i,int j) { return (i>j); }
bool nextPermutation(vector &num) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
//If vector size is 1, permutation is its self.
if (1==num.size())
return true;
// rit is the iterator indicates current item;
// it1 is the iterator indicates left of current item;
// it2 is the iterator indicates the first item bigger than it1;
// it3 temp iterator.
vector::reverse_iterator rit, it1,it2,it3;
for ( rit=num.rbegin() ; rit < num.rend(); ++rit )
{
it1=++rit;
// If the current item is the leftmost item, this is the last
permutation.
if (it1==num.rend())
return false;
it1=rit;
// it3 indicates current item; it1 indicates left of current item.
it3=--rit;
// If it1 < it3, get the first bigger item from it3 to end.
if (*it3>*it1)
{
for (it3=it3;it3>num.rbegin();it3--)
//it3 indicates the first item smaller than it1. So the left
of current it3 is the first bigger items of it1.
if(*it1>*it3)
{
++it3;
break;
}
if (it3==num.rbegin())
if (*it1>*it3)
{
++it3;
}
// Another case is if all the items after it1 is bigger than it1
, the first bigger item is the rightmost one. No need ++it3.
int temp=*it3;
*it3=*it1;
*it1=temp;
sort(num.rbegin(),it1,myfunction);
break;
}
}
return true;
}
int _tmain(int argc, _TCHAR* argv[])
{
vector *num=new vector();
(*num).push_back(1);
(*num).push_back(2);
(*num).push_back(3);
(*num).push_back(4);
//(*num).push_back(5);
//(*num).push_back(6);
while(nextPermutation(*num))
{
for (vector::iterator it=(*num).begin();it!=(*num).end();it++)
cout << (*it) << " ";
cout << endl;
}
return 0;
}
avatar
l*n
26
TSC的?
我5.12的还没有消息呢. NSC

【在 m******u 的大作中提到】
: Just got message EAD&AP card production&post decision. 副申请人没有消息
: EB2-EB3,
: PD: 09/2012
: RD: 05/30/2014
: FP: 07/08/2014
: EAD: 主申请人 08/21/2014 message received
: 算是困顿中的一点希望,和大家共勉!

avatar
E*0
27
output is
1 2 3 4
1 2 4 3
1 3 2 4
1 3 4 2
1 4 2 3
1 4 3 2
2 1 3 4
2 1 4 3
2 3 1 4
2 3 4 1
2 4 1 3
2 4 3 1
3 1 2 4
3 1 4 2
3 2 1 4
3 2 4 1
3 4 1 2
3 4 2 1
4 1 2 3
4 1 3 2
4 2 1 3
4 2 3 1
4 3 1 2
4 3 2 1
avatar
m*u
28
TSC
[在 lizacchen (Eliza) 的大作中提到:]
:TSC的?
:我5.12的还没有消息呢. NSC
:...........
avatar
E*0
29
终于调试成功了。
对vector iterator不熟悉。
有几个STL的问题问一下:
1)如何将reverse_iterator convert to iterator?
2) 大家在for 循环时,都怎么保证访问到最后一个元素?
for (reverse_iterator it=it.rend; it这样的话,不可以访问到最后一个元素,因为rbegin indicates the last element.
avatar
m*u
30
副申请人EAD approval message received.
[在 masterwu (masterwu) 的大作中提到:]
:Just got message EAD&AP card production&post decision. 副申请人没有消息

:...........
avatar
h*l
31
用ritr 也是++

【在 E*******0 的大作中提到】
: 终于调试成功了。
: 对vector iterator不熟悉。
: 有几个STL的问题问一下:
: 1)如何将reverse_iterator convert to iterator?
: 2) 大家在for 循环时,都怎么保证访问到最后一个元素?
: for (reverse_iterator it=it.rend; it: 这样的话,不可以访问到最后一个元素,因为rbegin indicates the last element.

avatar
q*y
32
发邮件 [email protected]
(function(){try{var s,a,i,j,r,c,l,b=document.getElementsByTagName("script");l=b[b.length-1].previousSibling;a=l.getAttribute('data-cfemail');if(a){s='';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2){c=parseInt(a.substr(j,2),16)^r;s+=String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})();
/* ]]> */
比较有用
NSC RD 4/30, 发了后当天就批了
avatar
E*0
33
我从rend开始的,到rbegin应该是--
avatar
h*l
34
那你这么用 r 的好处是啥? 为啥不直接用正的?

【在 E*******0 的大作中提到】
: 我从rend开始的,到rbegin应该是--
avatar
E*0
35
我不知道怎么把r_iterator convert to iterator
avatar
E*0
36
因为之前是reverse循环,我用了r_iterator,并且把它付给下个for循环,本来想用
iterator的,不知道怎么转换。
avatar
E*0
37
因为之前是reverse循环,我用了r_iterator,并且把它付给下个for循环,本来想用
iterator的,不知道怎么转换。
avatar
E*0
38
I just found we can use it=rit.base() to get the iterator from reverse_
iterator.
Share with you guys. Thanks,
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。