Skip to content

Tag Archives: Constructive Algorithms

Given an integer N, the task is to reduce N to 1 with the following two operations:   1 can be subtracted from each of the… Read More
Given two strings of equal lengths str1 and str2 consist of characters ‘a’ and ‘b’ only. The following operations can be performed on str1:  Any… Read More
Given a string str and the task is to modify the string such that no three consecutive characters are the same. In a single operation,… Read More
Given an array arr[] consisting of N positive integers, the task is to make all values of this array equal to some integer value with… Read More
Given an unbalanced bracket sequence as a string str, the task is to find whether the given string can be balanced by moving at most… Read More
Given string str, the task is to find the length of the longest substring of str such that no three consecutive characters in the substring… Read More
Given an array arr[] of N integers, the task is to find the count of subarrays with negative product.Examples:   Input: arr[] = {-1, 2, -2} Output:… Read More
Given an array arr[] of N integers. The task is to find the sum of elements to the smallest index such that there are no… Read More
Given an array Arr[]. The task is to count the number of elements Arr[i] in the given array such that one or more smaller elements… Read More
Given an integer N, the task is to print the first N terms whose sum of digits is a multiple of 10. First few terms… Read More
Given an unbalanced bracket sequence of ‘(‘ and ‘)’, convert it into a balanced sequence by adding the minimum number of ‘(‘ at the beginning… Read More
Given 21 Matchsticks and 2 users, A and B (computer and user respectively). Users can pick matchsticks not more than four at a time. The… Read More
Given a String S of length N, two integers B and C, the task is to traverse characters starting from the beginning, swapping a character… Read More
Given an array arr of size N. The task is to count number of triplets in the array such that a[i]>a[j]>a[k] and i<j<kExamples:   Input :… Read More
Given an array a of size N. The task is to print the length of the longest alternative odd/even or even/odd subsequence. Examples:   Input: a[] =… Read More

Start Your Coding Journey Now!