#introductory java help for study

1 messages · Page 1 of 1 (latest)

paper timberBOT
#

<@&987246527741304832> please have a look, thanks.

paper timberBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

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.

wary pine
#

can you give an example test case which fails?

ivory lance
#

FYI you can just do

if(!diffSet.add(diff)){
    isUsable = false;
    break;
}
quartz patio
#

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);
      }
    }
ivory lance
#

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)

paper timberBOT
#

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 👍