Write a Python program to find the first repeated character of a given string where the index of first occurrence is smallest
- برمجة
- برمجة بايثون
- 2021-04-15
- salsabeelalhams99111801528
الأجوبة
def first_repeated_char_smallest_distance(str1):
temp = {}
for ch in str1:
if ch in temp:
return ch, str1.index(ch);
else:
temp[ch] = 0
return 'None'
print(first_repeated_char_smallest_distance("abcabc"))
print(first_repeated_char_smallest_distance("abcb"))
print(first_repeated_char_smallest_distance("abcc"))
print(first_repeated_char_smallest_distance("abcxxy"))
print(first_repeated_char_smallest_distance("abc"))))أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال