Open saakshii12 opened 1 year ago
@saakshii12 I want to solve this issue. Please assign it to me.
@saakshii12 Can you please assign me this issue Sharwari FY Cummins college of engineering
def find_added_letter(s, t):
s_list = list(s)
t_list = list(t)
# Sort both lists to align similar characters
s_list.sort()
t_list.sort()
# Compare the two lists
for i in range(len(s_list)):
if s_list[i] != t_list[i]:
return t_list[i]
# If all the characters in s_list are matched, the last character in t_list is the added one
return t_list[-1]
example1 = find_added_letter("abcd", "abcde") example2 = find_added_letter("", "y")
print(example1) print(example2)
Write code in the preferred language and attach output with it.
You are given two strings s and t.
String t is generated by random shuffling string s and then add one more letter at a random position.
Return the letter that was added to t.
Example 1:
Input: s = "abcd", t = "abcde" Output: "e" Explanation: 'e' is the letter that was added.
Example 2:
Input: s = "", t = "y" Output: "y"