आसान 0 हल किए गए 0% स्वीकृति

First Unique Character

Find the first character that appears only once.

Return the index of the first character in text that appears exactly once. Case matters.

Implement first_unique_index(text).

Input

text: The text to inspect.

Output

Return the index, or -1 if every character repeats.

सीमाएँ

0 ≤ length ≤ 100,000

उदाहरण

उदाहरण 1
इनपुट:
text = "swiss"

अपेक्षित आउटपुट:
expected = 1
इनपुट:
std::string text = "swiss";

अपेक्षित आउटपुट:
long long expected = 1;
इनपुट:
string text = "swiss";

अपेक्षित आउटपुट:
long expected = 1;

व्याख्या

s repeats, w appears once at index 1.

उदाहरण 2
इनपुट:
text = "aabb"

अपेक्षित आउटपुट:
expected = -1
इनपुट:
std::string text = "aabb";

अपेक्षित आउटपुट:
long long expected = -1;
इनपुट:
string text = "aabb";

अपेक्षित आउटपुट:
long expected = -1;

व्याख्या

Every character repeats: -1.

संदर्भ

यह चुनौती CodeUtility के लिए अनुकूलित की गई है। ऊपर दिए गए स्टेटमेंट और सीमाओं का पालन करें।

दूसरों से सीखें

समुदाय समाधान

अभी तक कोई प्रकाशित समाधान नहीं। पहला साझा करने के लिए इस चुनौती को हल करें।