title: Find possible pairs from binary string
body: <p>I have an array of strings with values only 0 and 1.</p>
  <p>Example:
  [&quot;100&quot; , &quot;110&quot;, &quot;010&quot;, &quot;011&quot;, &quot;100&quot;]</p>
  <p>Now I want to take each string and compare it with all other strings and see how many of them differ by 1. For example:</p>
  <p>&quot;100&quot; compared with &quot;110&quot;, the element at each index is checked, if they are different by a maximum of 1 position then they are considered similar. So for String &quot;100&quot; in above array, the similar elements are &quot;110&quot; and &quot;100&quot;.</p>
  <p>My program returns an array of integers where each value indicates the number of similar strings at that index in list.</p>
  <p>Example:</p>
  <p>Input :</p>
  <p>[&quot;100&quot; , &quot;110&quot;, &quot;010&quot;, &quot;011&quot;, &quot;100&quot;]</p>
  <p>Output:
  [2,3,2,1,2]</p>
  <p>Explanation:
  At index 1, input is &quot;110&quot; the similar strings are 3 which are &quot;100&quot;, &quot;010&quot;, &quot;100&quot;.</p>
  <p>Here is my code:</p>
  <pre><code>static List&lt;Integer&gt; process(String[] input) {
      List&lt;Integer&gt; list = new ArrayList&lt;&gt;();
  
      for (int i = 0; i &lt; input.length; i++) {
          int count = 0;
          for (int j = 0; j &lt; input.length; j++) {
              if (i != j) {
                  int differ = 0;
                  for (int k = 0; k &lt; input[i].length(); k++) {
                      if (input[i].charAt(k) != input[j].charAt(k)) {
                          differ++;
                      }
                      if (differ &gt; 1) {
                          break;
                      }
                  }
                  if (differ &lt;= 1) {
                      count++;
                  }
              }
          }
          list.add(count);
      }
      return list;
  }
  </code></pre>
  <p>How can I improve the time complexity of this code?</p>
  <p>All Strings are of the same length and the length ranges from 1 to 20. Size of input array is up to 10,000.</p>