Posts

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));

ai generated video of flying ship #ai #stablediffusion #midjourney #aimu...

Image

Python revision notes || Direct download link 💯💯💯✅✅✅🔥🔥🔥

  Python Revision Notes Direct Download Link :)  Click on below link  Download

Python Revision Notes Cheat Sheet 🔥🔥🔥✅✅✅💯💯💯

Python Revision Notes :- Refer the below notes 👇👇👇

Row with maximum ones || Leetcode Solution || Simple Approach || 🔥🔥🔥💯💯💯✅✅✅||

                                                         2643.   Row With Maximum Ones  Link for Question :-  https://leetcode.com/problems/row-with-maximum-ones/description/ Solution :- Solving this problem using dictionary concept: Approach Of solving the problem :  Create a empty dictionary d = {} , initialise count = 0 , lst = [] Iterate over the mat list, now add dictionary for its index and count from the dictionary find the maximum value and store it in v_max variable Now iterate over the dictionary using .items() method Check condition if(value == v_max) append the key and value to the list and terminate the loop now, return the list Complexity Time complexity:  O ( n )       Since we used for loops  Code in Python: class Solution : def rowAndMaximumOnes ( self , mat : List [ List [ int ] ] ) - > List [ int ] : count = 0 d = { } for i in mat : d [ count ] = i . count ( 1 ) count += 1 v_list =