Open in app

Sign In

Write

Sign In

AVNISH KUMAR
AVNISH KUMAR

2 Followers

Home

About

Apr 10, 2022

Two odd occurring!

1. Two Odd occurring Introduction:- Given an array of the integer in which their are so many elements of length size of array "N" is present in such a way their are only two integer are present which appears odd number of times , rest occurred in even number of times. Our…

4 min read

Two odd occurring!
Two odd occurring!

4 min read


Apr 9, 2022

Check Power of 2

Three Approach we discussed here:- Naïve Approach Brian Kernighan’s Analysis of Brian Kernighan’s equation ( Efficient) a) Naive Approach Approach:- Algorithm :- 1. True(1) means power of 2 , False(0) means not the power of 2. 2. Divide the number by 2 , when we ends with the value of number as…

3 min read

Check Power of 2
Check Power of 2

3 min read


Apr 9, 2022

!!!**How to Count Set Bits**!!!

Three Approach we are going to Discussed:- a) Brute Force Approach -> O(bits) b) Brian Kernighan’s Algorithm -> O(set-bits) c) Lookup Table Method -> O(1) 1. Brute Force Approach:- Time Complexity :- O(bits) ~ O(N) where N is the length of bits. Approach:- For the Naïve Approach we take the…

Bitshares

3 min read

!!!**How to Count Set Bits**!!!
!!!**How to Count Set Bits**!!!
Bitshares

3 min read


Apr 9, 2022

Check k-the bit is set or not set!!

We can do this application using bit-manipulation using two method:- Left Shift operator. Note:- In the Left Shift method , we take example n=5 and k=3 n= 00000.....0101 (5) 1= 00000.....0100 (using left shift we shift the value 1) o/p= 00000.....0100 ( output is any +ve integer that means the at k-th position its set , 1 & 1= 1). 2. Right Shift operator. Note:- In the Right shift method , we take the same example n=5 and k=3 n= 0000....0101 (5) n>>(3-1) (right shift of n>>2) After the right shift operator we have n= 0000....0001 1= 0000....0001 n&1= 0000....0001 ( we have to get the value equivalent to 1 for the kth bit is set or not judgement.)

Bit

2 min read

Check k-the bit is set or not set!!
Check k-the bit is set or not set!!
Bit

2 min read


Mar 20, 2022

Frog Jump

Frog Jump /* *** Using Recursion :- Time Complexity :- O(2^N) Space Complexity:- O(N) 1. Break the problem in terms of indexes and observed over the questions. 2. Do computational work over the indexes , as here , based on indexes. 3. …

Dynamic Programming

2 min read

Frog Jump
Frog Jump
Dynamic Programming

2 min read


Mar 19, 2022

Climbing Stair

Climbing Stair /* Using Recursion:- Time Complexity:-(2^N) Space Complexity:- O(N) class Solution { public int climbStairs(int n) { if(n<=1){ return 1; } int left=climbStairs(n-1); int right=climbStairs(n-2); return left+right; } } */ /* Memoization:-(Top-Down) Time Complexity:- O(N) Space Complexity:- O(N)->Array + O(N)-> recursion stack class Solution { public int memo(int n,int [] dp){ if(n<=1) return 1; if(dp[n]>0){ return dp[n]; } int left=memo(n-1,dp); int right=memo(n-2,dp); dp[n]=left+right; return dp[n]; } public int climbStairs(int n) { int dp[]=new int[n+1]; return memo(n,dp); } }

Problem Solving

1 min read

Time Complexity:-(2^N)
Space Complexity:- O(N)
Time Complexity:-(2^N)
Space Complexity:- O(N)
Problem Solving

1 min read

AVNISH KUMAR

AVNISH KUMAR

2 Followers

Help

Status

Writers

Blog

Careers

Privacy

Terms

About

Text to speech