title: Each character just after its consecutive occurrences
body: <p>I'm solving this problem using Go:
  <a href="https://www.geeksforgeeks.org/printing-frequency-of-each-character-just-after-its-consecutive-occurrences/" rel="nofollow noreferrer">https://www.geeksforgeeks.org/printing-frequency-of-each-character-just-after-its-consecutive-occurrences/</a></p>
  
  <pre><code>package main
  
  import (
      "fmt"
      "strconv"
      "strings"
  )
  
  func main() {
  
      str := "GeeeEEKKKss"
      strArr := strings.Split(str, "")
  
      for i := 0; i &lt; len(strArr); i++ {
  
          count := 1
          nxtIdx := i + 1
          for nxtIdx &lt; len(strArr) &amp;&amp; strArr[nxtIdx] == strArr[i] {
              i++
              count++
          }
  
          fmt.Print(strArr[i], strconv.Itoa(count))
  
      }
      fmt.Println()
  
  }
  </code></pre>
  
  <blockquote>
    <p>When I'm directly using i+1 in place of "nxtIdx" variable, I'm getting expected result
     : G1e3E2K3s2</p>
    
    <p><a href="https://play.golang.org/p/wJBpNbIzlNd" rel="nofollow noreferrer">https://play.golang.org/p/wJBpNbIzlNd</a></p>
    
    <p>But when I'm using "nxtIdx" variable, I'm getting unexpected result
     : G1E4E1s4s1</p>
    
    <p><a href="https://play.golang.org/p/g8hejYTv2-0" rel="nofollow noreferrer">https://play.golang.org/p/g8hejYTv2-0</a></p>
  </blockquote>