Friday, February 1, 2019

Finding the occurrence of an integer

  • Problem Description

    Find the given integer in the given list of integers and print the number of occurrences of that integer in the list.
  • CODING ARENA
  • a=int(input())
    x=[]
    count=0
    for i in range(a):
        b=int(input())
        x.append(b)
    key=int(input())
    for i in range(a):
        if(key==x[i]):
            count+=1
    print(count)Test Case 1

  • Input (stdin)
    7
    
    64 
    
    34 
    
    7 
    
    12
    
    22 
    
    11 
    
    7
    
    7
    
    
    Expected Output
    2
  • Test Case 2

    Input (stdin)
    7
    
    64 
    
    34 
    
    45 
    
    34 
    
    24 
    
    29 
    
    34
    
    34
    
    
    Expected Output
    3

No comments:

Post a Comment