Does anyone want to do my homework?
no
kys
ok
>>58681373
The answer is 2.
meeeeeeeh :( tempting
>>58681373
i finished your homework seconds ago.
definitly wasted to much time at 5
KKKKKKKKKKKKK
>>58681373
>>58681373
Make j= i+1 on initialization, and make I go to A.length -1. (This prevents out of bounds indexing)
Fuck
It literally tells you how to do it
That's some next level laziness
>>58682592
True. Not that it matters much OP, but you could also return early if you found a duplicate:
public static boolean hasDuplicates(int []A){
for (int i=0;i<A.length;i++)
for (int j=i+1;j<A.length;j++)
if(A[i]==A[j])
return true;
return false;
}
In the worst case you still got
(n-1) + (n-2) + ... + 0 = n*(n-1)/2
inner loops though, so the algorithm is still quadratic. You also got n outer loops.
:(
public static boolean hasDuplicates(int []A){
int len = A.length
for (int i=0;i<len-1;i++)
for (int j=i+1;j<len;j++)
if (A[i]==A[j])
return true;
return false;
}
>>58681373
>mergesort
>>58681373
Wish I knew how to code
But all I do is build pc's and have a tiny penis
>>58681373
BLANKITY
BLANKITY
BLANK
Fuck it
sdikdsififjvihond fhifvuv ujbdf ufd udf uiofjif vijf dijdf ijfd n
>>58681373
do your own homework fag or you wont pass the test
>>58681373
> Continue the for loops even when the result is determined.
Your teacher is a retard. Sorry senpai
>>58681373
>literally can't do job interview questions
Change majors.
You can find pajeets on Reddit that will charge you like 3 bucks to do simple shit like this.
If you're retarded but forced to stay in college/highschool for whatever reason (parents pressure, etc.) it might be worth it to find a pajeet willing to work long term for you. They might even give you a discount.
>>58681373
How in the world do you expect to make it through this whole major if you can't be bothered to do intro material? Man up.
If you can't handle something of this level, consider Women's studies.
I'm a potato
Use a hash set and you won't need to worry about going o(n^2)