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

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

 

Employees whose manages left their company : 👇👇👇💯 




Leetcode Solution:-- 

Intuition

To find the manager who left the company, whose salary is less than 30000 dollars

Approach

step 1: filter the rows whose salary is strictly less than $30000

select *
from employees
where salary <= 30000

 Here manager_id = 6 left the company (because it isn't in employee_id column)

step 2: we need to find the manager how left the company. This we can find by searching it in employee_id from employees table (with a sub query ).

select employee_id  
from employees 
where salary <= 30000 
and manager_id not in (select employee_id from employees)

step 3: we need to order the table by employee_id.


Code

# Write your MySQL query statement below
select employee_id  
from employees 
where salary <= 30000 and manager_id not in (select employee_id from employees)
order by employee_id;






Please go through my blog and find more solutions :- )) 


Happy Learning :-)











Comments

Popular posts from this blog

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

HOW TO PREPARE FOR JEE MAINS IN HOME EFFECTIVELY