title: Repeating digits in number C++
body: <p>The task is to write a function which takes a number and finds the digit that is repeated most times in that number. It should print the found digit and the times it is repeated.</p>
  
  <p>I had a problem with the case when two digits were repeating a same number of times.</p>
  
  <p>For example with given number <code>788995</code> it should return <code>8 -&gt; 2 \\ 9 -&gt; 2</code>
  How can I print that?</p>
  
  <p>Here is the function: </p>
  
  <pre><code>void maxDigitInNumber (long long n)
  {
      if (n &lt; MIN || n &gt; MAX)
      {
          cout &lt;&lt; -1;
          return;
      }
  
      n = abs(n);
      int numOfDigits = (int)log10(n)+1;
      int digits[100];
      int helper[100] = {0};
      int counter = 0;
      int maxSize = 0;
      int number = 0;
  
  
  
      for (int i = 0; i &lt;= numOfDigits; i++)
      {
          digits[i] = n%10;
          n /= 10;
      }
  
      for(int i = 0; i &lt; numOfDigits; i++)
      {
          if(helper[i] == 0)
          {
              counter = 0;
  
              for(int j = i; j &lt; numOfDigits; j++)
              {
                  if(digits[j] == digits[i])
                  {
                      counter++;
                      helper[j] = 1;
                  }
                  if(counter &gt; maxSize)
                  {
                      maxSize = counter;
                      number = digits[i];
  
                  }
              }
  
          }
  
      }
  
      if (number == 0)
      {
          for (int i = 0; i &lt; numOfDigits; i++)
          {
              cout &lt;&lt; digits[i] &lt;&lt; "-&gt;" &lt;&lt; maxSize &lt;&lt; endl;
          }
      }
      else
      {
          cout &lt;&lt; number &lt;&lt; "-&gt;" &lt;&lt; maxSize &lt;&lt; endl;
      }
  }
  </code></pre>