Home
Gaurav's GitHub Page
Cancel

Power of 2 (geeksforgeeks - SDE Sheet)

PROBLEM DESCRIPTION Given a non-negative integer n. The task is to check if it is a power of 2. geeksforgeeks SOLUTION The number of set bits should be 1. class Solution { public static b...

Toggle bits in the given range (geeksforgeeks - SDE Sheet)

PROBLEM DESCRIPTION Given a non-negative number n and two values l and r. The problem is to toggle the bits in the range l to r in the binary representation of n, i.e., to toggle bits from the lth...

Set kth bit (geeksforgeeks - SDE Sheet)

PROBLEM DESCRIPTION Given a number N and a value K. From the right, set the Kth bit in the binary representation of N. The position of Least Significant Bit(or last bit) is 0, the second last bit ...

Number is sparse or not (geeksforgeeks - SDE Sheet)

PROBLEM DESCRIPTION Given a number N. The task is to check whether it is sparse or not. A number is said to be a sparse number if no two or more consecutive bits are set in the binary representati...

Bit Difference (geeksforgeeks - SDE Sheet)

PROBLEM DESCRIPTION You are given two numbers A and B. The task is to count the number of bits needed to be flipped to convert A to B. geeksforgeeks SOLUTION class Solution { public static...

N-Queen Problem (geeksforgeeks - SDE Sheet)

PROBLEM DESCRIPTION The n-queens puzzle is the problem of placing n queens on a (n×n) chessboard such that no two queens can attack each other. Given an integer n, find all distinct solutions to t...

Rat in a Maze Problem - I (geeksforgeeks - SDE Sheet)

PROBLEM DESCRIPTION Consider a rat placed at (0, 0) in a square matrix mat of order n* n. It has to reach the destination at (n - 1, n - 1). Find all possible paths that the rat can take to reach ...

Special Keyboard (geeksforgeeks - SDE Sheet)

PROBLEM DESCRIPTION Imagine you have a special keyboard with the following keys: Key 1: Prints ‘A’ on screen Key 2: (Ctrl-A): Select screen Key 3: (Ctrl-C): Copy selection to buffer Key ...

Word Boggle (geeksforgeeks - SDE Sheet)

PROBLEM DESCRIPTION Given a dictionary of distinct words and an M x N board where every cell has one character. Find all possible words from the dictionary that can be formed by a sequence of adja...

Tower Of Hanoi (geeksforgeeks - SDE Sheet)

PROBLEM DESCRIPTION The tower of Hanoi is a famous puzzle where we have three rods and n disks. The objective of the puzzle is to move the entire stack to another rod. You are given the number of ...