code: private static int row(int[] r, int f) {
          int i = 0;
  
          while (i < r.length && r[i] < f) {
              ++i;
          }
  
          return ((i < r.length && r[i] == f) ? i : -1);
      }
docs: Returns the index of given frequency.
  @param r the frequency list.
  @param f the given frequency.
  @return the index of given frequency or -1 if it doesn't exist in the list.