I am getting a type mismatch here? Am I not create a HashMap of key char and value int? Is i some type of iterator instead of a int?
import scala.collection.mutable.HashMap
object Solution {
def firstUniqChar(s: String): Int = {
var hashMapName = HashMap[Char, Int]();
for (i <- 0 until s.length){
if (hashMapName.contains(s.charAt(i)) ) return i-1
else hashMapName = hashMapName + (s.charAt(i), i)
println(s.charAt(i))
}
return -1;
}
}