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...
Transpose of a Matrix
PROBLEM DESCRIPTION Write a program to find the transpose of a square matrix of size N*N. Transpose of a matrix is obtained by changing rows to columns and columns to rows. geeksforgeeks SOLUTIO...
Even Subarrays
PROBLEM DESCRIPTION You are given an integer array A. Decide whether it is possible to divide the array into one or more subarrays of even length such that the first and last element of all subarr...
Closest MinMax
PROBLEM DESCRIPTION Given an array A of size N. The task is to find the length of smallest subarray which contains both maximum and minimum values. geeksforgeeks SOLUTION APPROACH 1 First we g...
Pick from both sides!
PROBLEM DESCRIPTION Given an integer array A of size N. You have to pick exactly B elements from either left or right end of the array A to get the maximum sum. Find and return this maximum possib...
Balance Array (Special Index)
PROBLEM DESCRIPTION Given an integer array A of size N. You need to count the number of special elements in the given array. A element is special if removal of that element make the array balanced...
Serialize and Deserialize Binary Tree
PROBLEM DESCRIPTION Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a netwo...
Sliding Window Maximum
Problem Description You are given an array of integers nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers i...
Minimum Window Substring
Problem Description Given two strings s and t of lengths m and n respectively, return the minimum window substring of s such that every character in t (including duplicates) is included in the win...