c program to clear nth bit of the number || Bitwise Operators || Problem Solving ||

#include <stdio.h> int main() {     int num, n, newNum;     printf("Enter any number: ");     scanf("%d", &num);     printf("Enter nth bit to clear (0-31): ");     scanf("%d", &n);     newNum = num & (~(1 << n));     printf("Number before clearing %d bit: %d (in decimal)\n", n, num);     printf("Number after clearing %d bit: %d (in decimal)\n", n, newNum);     return 0; } Logic :-  num&(~(1<<n));

Find the second lowest grade in the nested list:

Given the names and grades for each student in a class of  students, store them in a nested list and print the name(s) of any student(s) having the second lowest grade.


Hacker Rank Solution:  

 if __name__ == '__main__':

    student_list = []
    for _ in range(int(input())):
        name = input()
        score = float(input())
        student_list.append([name,score])
    # print(student_list)    
    
scores_list = sorted(list(set([student[1] for student in student_list])))
# print(scores_list)
second_lowest_grade = scores_list[1]
student_second_lowest_grade = [
    student[0] 
    for student in student_list
    if(student[1]==second_lowest_grade)


]
student_second_lowest_grade.sort()
for i in student_second_lowest_grade:
    print(i)

Comments

Popular posts from this blog

Merge Strings Alternatively || Leetcode Solution || Easy Approach || Simple || ✅✅✅✅💯💯💯💯🔥🔥🔥🔥

HOW TO PREPARE FOR JEE MAINS IN HOME EFFECTIVELY

1978. Employees Whose Manager Left the Company || Leetcode SQL solution || simple sql query || 🔥🔥🔥💯💯💯✅✅✅