title: String s="red,green,green,red,red,green,green,red"; if the combination will occur more than once "red,green" or "Green,red".(Count)
body: <p>I have a comma-separated string which have words:</p>
  <pre><code>String s = &quot;red,green,green,red,red,green,green,red&quot;;
  </code></pre>
  <p>if the combination occurs more than once &quot;red,green&quot; or &quot;Green,red&quot;, I want to capture the number of occurrences in the string (count). Could anyone help me with this for better time and space complexity solution?</p>