大家推荐个显卡给 T3500 吧# Hardware - 计算机硬件
b*y
1 楼
Given a table A of N integers from 0 to N-1 calculate the smallest such inde
x P, that that {A[0],...,A[N-1]} = {A[0],...,A[P]}.
测试的时候timeout了,可能时间复杂度过高,不知道怎么改。
int ps ( int[] A ) {
// write your code here
int size = A.length;//数组长度
int p = 0;//返回的index
int j = 1;//用于比较的index,与A[0]-A[j-1]比较,看是否存在重复
while(j < size)
{
int ex = 0; //记录是否出现重复
for(int i = 0; i < j; i++)
{
if(A[i] == A[j])
{
ex = 1;
break;
}//出现重复值
}
if(ex == 0)//无重复值
p = j;
j++;
}
return p;
}
x P, that that {A[0],...,A[N-1]} = {A[0],...,A[P]}.
测试的时候timeout了,可能时间复杂度过高,不知道怎么改。
int ps ( int[] A ) {
// write your code here
int size = A.length;//数组长度
int p = 0;//返回的index
int j = 1;//用于比较的index,与A[0]-A[j-1]比较,看是否存在重复
while(j < size)
{
int ex = 0; //记录是否出现重复
for(int i = 0; i < j; i++)
{
if(A[i] == A[j])
{
ex = 1;
break;
}//出现重复值
}
if(ex == 0)//无重复值
p = j;
j++;
}
return p;
}