Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.

Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).

class Solution(object): def firstUniqChar(self, str1): """ :type s: str :rtype: int """ for x in str1: if str1.find(x)==str1.rfind(x): return str1.find(x) return -1

Isn't the worst case complexity O(n^2)?

This is a simple solution, but the complexity is pretty bad. The worst case complexity is O(n^2), when a better solution can yield O(n) complexity.

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.