#introductory java help for study
1 messages · Page 1 of 1 (latest)
While you are waiting for getting help, here are some tips to improve your experience:
If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.
Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.
can you give an example test case which fails?
FYI you can just do
if(!diffSet.add(diff)){
isUsable = false;
break;
}
u can do
loop: for (int i = 0; i < n - 1; i++) {
for (int j = i + 1; j < n; j++) {
int diff = Math.abs(seq[i] - seq[j] );
if (diffSet.contains(diff)) break loop;
else diffSet.add(diff);
}
}
Technically yes but you shouldn't use labels
You could however, extract both loops into a method of their own
Which returns false inside the second loop if a duplicate us found
And returns true outside both loops(indicating no duplicates were found)
Closed the thread due to inactivity.
If your question was not resolved yet, feel free to just post a message to reopen it, or create a new thread. But try to improve the quality of your question to make it easier to help you 👍