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

Password Modifier

Strengthen a password by swapping some letters for symbols and adding its length at the end.

आप क्या सीखेंगे

  • Walk through a string one character at a time
  • Map characters to replacements
  • Append a number converted to text

समस्या

अनुवाद दिखाएँ

A school IT club suggests a quick way to turn a simple word into a stronger password. Swap these lowercase letters for look-alike symbols:

LetterBecomes
a@
e3
i!
o0 (zero)
s$

Every other character stays as it is (capital letters are not swapped). Then add # and the length of the original word at the end.

Implement password_modifier(word).

Input

word: The starting word.

Output

Return the new password.

सीमाएँ

0 ≤ length of word ≤ 100

word uses printable ASCII characters

उदाहरण

उदाहरण 1
इनपुट:
word = "mississippi"

अपेक्षित आउटपुट:
expected = "m!$$!$$!pp!#11"
इनपुट:
std::string word = "mississippi";

अपेक्षित आउटपुट:
std::string expected = "m!$$!$$!pp!#11";
इनपुट:
string word = "mississippi";

अपेक्षित आउटपुट:
string expected = "m!$$!$$!pp!#11";

व्याख्या

Every i becomes ! and every s becomes $, and the word has 11 letters: "m!$$!$$!pp!#11".

उदाहरण 2
इनपुट:
word = "Oreo"

अपेक्षित आउटपुट:
expected = "Or30#4"
इनपुट:
std::string word = "Oreo";

अपेक्षित आउटपुट:
std::string expected = "Or30#4";
इनपुट:
string word = "Oreo";

अपेक्षित आउटपुट:
string expected = "Or30#4";

व्याख्या

The capital O stays, e becomes 3 and the last o becomes 0; the length is 4: "Or30#4".

कैसे हल करें

पहले खुद कोशिश करें, फिर एक-एक करके संकेत खोलें।

संकेत 1

Look at each character and decide what to write in its place.

संकेत 2

Only the five lowercase letters change; everything else is copied.

संकेत 3

Use the length of the original word, then convert it to text before adding it.

अपेक्षित जटिलता

O(n) time, O(n) extra space

संदर्भ

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

हर कोडर का सबसे अच्छा पास हुआ समाधान। तेज़, कम मेमोरी वाले और बेहतर रेटिंग वाले समाधान ऊपर रहते हैं।

अभी कोई पास हुआ समाधान नहीं है। इसे हल करें और पहला स्थान पाएँ।

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

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

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