Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Since you haven't actually tried any code, I'll give a description of how to solve this problem, but no actual code.</p> <p>Start with a <code>boolean</code> like <code>pairFound</code> that's initialized to <code>false</code> and change to <code>true</code> when you find your first <code>pair</code>. Additionally, you'll need an <code>int</code> (<code>pairValue</code> to keep track of the value of the first pair found (if you found one).</p> <p>Iterate through, looking for a pair. If you find a pair, and <code>pairFound</code> is false, set <code>pairFound</code> to <code>true</code>, and set <code>pairValue</code> to the value of your first found <code>pair</code>. Now keep iterating through.</p> <p>If you find a pair and <code>pairFound</code> is <code>true</code> and the pair is <code>!= pairValue</code>, then <code>return true;</code>. If you iterate through everything and haven't returned <code>true</code> yet, then you can <code>return false</code>.</p> <hr> <p>Based on your updated question, you're pretty close.</p> <pre><code>boolean pairFound = false; int pairValue = Integer.MIN_VALUE; //or some value that arrayOfInts will never have based on context for(int s = 0; s &lt; arrayOfInts.length - 1; s++){ if(arrayOfInts[s] == pairValue) { continue; } for(int c = s + 1; c &lt; arrayOfInts.length; c++){ if(arrayOfInts[s] == arrayOfInts[c]) { if(arrayOfInts[s] != pairValue) { if(pairFound) { return true; } pairValue = arrayOfInts[s]; pairFound = true; break; } } } } return false; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload