title: Check whether occurrence of individual digit in a number is same or not
body: <blockquote>
    <p>We need to check whether the occurrence of an individual digit in a number is same or not.For e.g. for 2244 (2 occur 2 times and 4 occur 2 times).Therefore, occurrence of both digits are same.</p>
  </blockquote>
  
  <pre><code>//This will return true if occurrence of individual digit in
  //a number is same else false
  
  bool stable(int no)
  {
      vector&lt;int&gt; v1;
      int k , count = 1;
      int arr[10];
      //Initializing all arr[] -&gt; 0
      for(int k = 0 ; k &lt; 10 ;k++)
      {
          arr[k] = 0;
      }
      while(no != 0)
      {
          k=no%10;
          arr[k]++;
          no=no/10;
      }
      for(int i = 0 ; i &lt; 10 ; i++)
      {
          if(arr[i] != 0)
          {
              v1.push_back(arr[i]);  //storing count of individual digits
          }
      }
      vector&lt;int&gt;::iterator it , it2;
      for(it = v1.begin()+1 ,it2 = v1.begin(); it != v1.end() ; it++,it2++)
      {
          if(*it == *it2) //if all the values are same return true else false
          {
              count++;
          }
      }
      if(count == v1.size()) return true;
          return false; 
  }
  </code></pre>
  
  <p>But this code doesn't work for no like 2222,1111,444. Also, would you suggest some good way to optimize the code?</p>