Advertisement
TheRedRover

Untitled

Apr 8th, 2020
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.38 KB | None | 0 0
  1. object Dups {
  2.   def duplicateCount(str: String): Int ={
  3.     def helper (str:String, acc:Int): Int ={
  4.       if(str.length>1) {
  5.         val str1 = str.toLowerCase.filterNot(str.toLowerCase.charAt(0).toString.toSet)
  6.         if(str.length-str1.length>1){
  7.           helper(str1,acc+1)
  8.         }
  9.         else helper(str1,acc)
  10.       }
  11.       else acc
  12.     }
  13.     helper(str,0)
  14.   }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement