Home
Gaurav's GitHub Page
Cancel

Gray Code

PROBLEM DESCRIPTION An n-bit gray code sequence is a sequence of 2n integers where: Every integer is in the inclusive range [0, 2n - 1], The first integer is 0, An integer appears no more ...

Sum of Bitwise-OR of all Sub-Arrays

PROBLEM DESCRIPTION You are given an array of integers A of size N. The value of a subarray is defined as BITWISE OR of all elements in it. Return the sum of value of all subarrays of A % 109 + 7....

Diffk II

PROBLEM DESCRIPTION Given an array A of integers and another non negative integer B . Find if there exists 2 indices i and j such that A[i] - A[j] = B and i != j. interviewbit SOLUTION public c...

Largest Continuous Sequence Zero Sum

PROBLEM DESCRIPTION Given an array A of N integers. Find the largest continuous sequence in a array which sums to zero. interviewbit SOLUTION Related Post: Sub-Array with 0 Sum public class So...

First Repeating element

PROBLEM DESCRIPTION Given an integer array A of size N, find the first repeating element in it. We need to find the element that occurs more than once and whose index of first occurrence is smalle...

tolower()

PROBLEM DESCRIPTION You are given a function to_lower() which takes a character array A as an argument. Convert each character of A into lowercase characters if it exists. If the lowercase of a c...

Josephus Problem

PROBLEM DESCRIPTION Given the total number of persons n and a number k which indicates that k-1 persons are skipped and kth person is killed in circle in a fixed direction. After each operation, t...

Majority Element

PROBLEM DESCRIPTION Given an array nums of size n, return the majority element. The majority element is the element that appears more than ⌊n / 2⌋ times. You may assume that the majority element ...

Help From Sam

PROBLEM DESCRIPTION Alex and Sam are good friends. Alex is doing a lot of programming these days. He has set a target score of A for himself. Initially, Alex’s score was zero. Alex can double his ...

Length of longest consecutive ones

PROBLEM DESCRIPTION Given a binary string A. It is allowed to do at most one swap between any 0 and 1. Find and return the length of the longest consecutive 1’s that can be achieved. SOLUTION pu...