HackerRank problem solution

 

1. Lonely Integer problem 




In this HackerRank Lonely Integer problem solution, we have Given an array of integers, where all elements but one occur twice, find the unique element.

Problem solution in Python

def lonelyinteger(a):
    for x in a:
        ax = a.count(x)
        if ax == 1:
            return x


 

2. Grading Student problem


Problem solution in Python

    
    def gradingStudents(grades):
    
    for x in grades:
        dif = ((int(x/5)*5)+5)-x
        if  dif<3 and x>37:
            grades[grades.index(x)]=((int(x/5)*5)+5)
        else:
            grades[grades.index(x)] = x
                
    return grades





Comments

Popular posts from this blog

Why Is it necessary not to change ?

Gargoti Mineral Museum