Count balanced substring
For input "abccba" Balanced substring are "cc" , "bccb" , "abccba" ie
  count=3 (Provided as per problem statement discussion) But I guess
  "aa", "bb", "cc", "abba", "acca", "cbbc" are also balanced sub string
  for the same input which makes count=6. Any wrong in my interpretation
  ?


A substring is a string that appears unbroken within another string. So for example, the provided answers are substrings

cc       ab|cc|ba
bccb     a|bccb|a
abccba   |abccba|


The other balanced substrings "aa", "bb", "cc", "abba", "acca", and "cbbc" are not substrings but a subset (w/ duplicates) of the characters in the original string.

The main thing to note is that order of the characters as well as the count of each characters matters.

EDIT: Formal Definition of Substring

@OP: Beware not to confuse substring with Subsequence