Sort by

recency

|

1633 Discussions

|

  • + 0 comments

    from collections import Counter N = int(input()) D = [] for i in range(N): D.append(input()) print(len(set(D))) print(*Counter(D).values())

  • + 0 comments
    from collections import OrderedDict
    
    n = int(input())
    count = 0
    inp_dict = OrderedDict()
    
    for i in range(n):
        word = str(input())
        
        if word in inp_dict:
           inp_dict[word] += 1
        else:
            inp_dict[word] = 1
            count +=1
            
    print(count)
    print(*(inp_dict[word] for word in inp_dict))
    
  • + 0 comments

    from collections import Counter n =int(input()) li=[]

    for i in range(n): word=input() li.append(word)

    count_words=len(set(li)) print(count_words)

    counts = Counter(li)

    for count in counts.values(): print(count,end=" ")

  • + 0 comments

    n = int(input())

    dic = {}

    for _ in range(n): word = input() if word in dic.keys(): dic[word]+=1 else: dic[word] = 1

    print(len(dic.keys()))

    occ = [str(i) for i in dic.values()]

    print(' '.join(occ))

  • + 0 comments

    Here is HackerRank Word Order in python solution - https://programmingoneonone.com/hackerrank-word-order-problem-solution-in-python.html