title: how to delete the elements that have the same prefix String (2 to 5 Chars) in a List?
body: <p>there is a List as below:</p>
  
  <pre><code>val a: List[String] = List(aaaaa1, aaaaa2, bb, cc, dd1, ee, dd2, dd3, ff, ggg1, ggg2, aaaaa3)
  </code></pre>
  
  <p>how to delete the elements that have the same prefix String (2 to 5 Chars) in a List?</p>
  
  <p>for example: </p>
  
  <p>"aaaaa1","aaaaa2","aaaaa3" have the same prefix String "aaaaa"(5 Chars). so delete them.</p>
  
  <p>"dd1","dd2","dd3" have the same prefix String "dd"(2 Chars). so delete them.</p>
  
  <p>"ggg1","ggg2" have the same prefix String "ggg"(3 Chars). so delete them.</p>
  
  <p>expected:</p>
  
  <pre><code>val b: List[String] = List(bb,cc,ee,ff)
  </code></pre>
  
  <p>==========</p>
  
  <p>thx for your idea. now fix it.</p>
  
  <pre><code>a.foldLeft(scala.collection.mutable.LinkedHashMap[String,Int]().withDefaultValue(0)){
    case(m,e) =&gt;
      val k = e.take(2)
      m(k)+=1
      m
  }.filter(_._2==1).keys.toList
  </code></pre>