Back

print the least repeated characters in the string

Created 3 years ago
208 Views
4 Comments
kreetykishore
@kreetykishore
kreetykishore
@kreetykishoreProfile is locked. Login

Given a string, print the least repeated characters in the string.If there are more than one character repeated preserve the order as in the input.
Input Size : 1 <= N <= 100000
Sample Testcase :
INPUT
codeKata challenge
OUTPUT
odKthng

my syntax is

#take user input
String = input()
for i in String:
    #initialize a count variable
    count = 0
    for j in String:
        #check for repeated characters
        if i == j:
            count+=1
        #if character is found more than 1 time
        #brerak the loop
        if count > 1:
            break
    #print for nonrepeating characters
    if count == 1:
        print(i,end = " ")

it prints the output as odKt hng

the correct answer is there should be no space between odKt and hng

kindly provide the correct syntax

Comments (4)
Please login to comment.