Question: in python first unique character A unique character is one that appears only once in a string. Given a string consisting of lowercase English letters

in python

first unique character

A unique character is one that

appears only once in a string.

Given a string consisting of

lowercase English letters only,

return the index of the first

occurrence of a unique

character in the string using 1-

based indexing. If the string

does not contain any unique

character, return -1.

Example

S=

"statistics"

The unique characters are [a,

c] among which a occurs first.

Using 1-based indexing, it is at

index 3.

Function Description

Function Description

Complete the function

getUniqueCharacter in the

editor below.

getUniqueCharacter has the

following parameter(s):

strings: a string

Returns

int: either the 1-based index

or -1

constraints

1 ? length of s ? 10^5

the string s consist of lowercase english letters only

Input Format For

Custom Testing

The first line contains a

strife, s.

Sample Input For Custom

Testing

hackthegame

Sample Output

3

Explanation

The unique characters are

[c, k, t, g, m]out of which

the character c occurs first, at index 3

Step by Step Solution

3.47 Rating (163 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Intro In Python a dictionary is a collection of keyvalue pairs It is an unordered data structure that stores data in a collection of keyvalue pairs we ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!