PROBLEM DESCRIPTION You are given a 0-indexed integer array nums of size n and a positive integer k. We call an index i in the range k <= i < n - k good if the following conditions are sati...
First Missing Positive
PROBLEM DESCRIPTION Given an unsorted integer array nums, return the smallest missing positive integer. You must implement an algorithm that runs in O(n) time and uses constant extra space. leetc...
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 ...