We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. Prepare
  2. Python
  3. Collections
  4. Word Order
  5. Discussions

Word Order

Problem
Submissions
Leaderboard
Discussions
Editorial

Sort 1354 Discussions, By:

recency

Please Login in order to post a comment

  • bongoehit
    1 day ago+ 1 comment
    n = int(input())
    
    arr = []
    for i in range(n):
        arr.append(input())
        
    K = (sorted(set(arr), key = arr.index ))  
    
    count = []
    
    for i in range(0,len(K)):
        
        count.append(0)
        for j in range(0,len(arr)):    
            if(K[i] == arr[j]):
                count[i] = count[i] + 1
                
    print(len(K))
    print(*count, sep=" ")
    
    0|
    Permalink
  • efremovdti
    5 days ago+ 0 comments
    from collections import Counter
    
    n = int(input())
    words_list = [input() for n in range(n)]
    words_count = Counter(words_list)
    
    print(len(words_count))
    print(*words_count.values())
    
    0|
    Permalink
  • spoudel522
    1 week ago+ 0 comments

    from collections import Counter n=int(input()) l=[] for i in range(0,n): l.append(input()) x=Counter(l) #counter method will return the character and its no of occurance in dictionay print(len(x)) print(*x.values()) #unpaking dictionay values

    0|
    Permalink
  • adhiraj_majumda1
    1 week ago+ 0 comments

    Easy to understand solution

    n = int(input())
    
    dictV={}
    lists = []
    for i in range(n):
        lists.append(input())
    
    for i in lists:
        if i in dictV:
            dictV[i]+=1
        else:
            dictV[i]=1
    output = list(dictV.values())
    print(len(dictV))
    print(' '.join(str(i) for i in output))
    
    1|
    Permalink
  • adhiraj_majumda1
    1 week ago+ 0 comments

    Easy to understand solution

    Enter your code here. Read input from STDIN. Print output to STDOUT

    n = int(input())

    dictV={} lists = [] for i in range(n): lists.append(input())

    for i in lists: if i in dictV: dictV[i]+=1 else: dictV[i]=1 output = list(dictV.values()) print(len(dictV)) print(' '.join(str(i) for i in output))

    0|
    Permalink
Load more conversations

Need Help?


View editorial
View top submissions
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy