Sobes.tech
Junior — Senior

Determining the index of the first unique character in a string

livecode

Task condition

Given a string s. Find the first character that appears only once and return its index. If there are no characters in the string that satisfy the condition, return -1.

Examples:

val s = "hutrihbp" // (u) result = 1
val s = "abcabce" // (e) result = 6
val s = "uuee"    // () result = -1