## Program to build a DFA to accept strings that start and end with same character

Given a string consisting of characters a and b, check if the string starts and ends with the same character or not. If it does,… Read More »

## Find Nth term of the series 2, 3, 10, 15, 26….

Given a number N, the task is to find the Nth term in series 2, 3, 10, 15, 26…. Example: Input: N = 2 Output:… Read More »

## Find the Nth term in series 12, 35, 81, 173, 357, …

Given a number N, the task is to find the Nth term in series 12, 35, 81, 173, 357, … Example: Input: N = 2… Read More »

## Find Nth term of the series 4, 2, 2, 3, 6, …

Given a number N, the task is to find the N-th term in series 4, 2, 2, 3, 6, … Example: Input: N = 2… Read More »

## Program to build a DFA that accepts strings starting and ending with different character

Prerequisite: Deterministic Finite Automata Given a string str consists of characters ‘a’ & ‘b’. The task is to check whether string str starts and ends… Read More »

## Program to build a DFA that checks if a string ends with “01” or “10”

DFA or Deterministic Finite Automata is a finite state machine which accepts a string(under some specific condition) if it reaches a final state, otherwise rejects… Read More »

## Count of pairs satisfying the given condition

Given two integers A and B, the task is to calculate the number of pairs (a, b) such that 1 ≤ a ≤ A, 1… Read More »

## Smallest number greater than n that can be represented as a sum of distinct power of k

Given a number n and a value k, the task is to find the smallest m(m>=n), such that m can be represented as a sum… Read More »

## Maximize the sum of differences of consecutive elements after removing exactly K elements

Given a sorted array arr[] of length N and an integer K such that K < N, the task is to remove exactly K elements… Read More »

## Find the final number obtained after performing the given operation

Given an array of positive distinct integers arr[], the task is to find the final number obtained by performing the following operation on the elements… Read More »

## Split the binary string into substrings with equal number of 0s and 1s

Given a binary string str of length N, the task is to find the maximum count of substrings str can be divided into such that… Read More »

## Check whether all the substrings have number of vowels atleast as that of consonants

Given a string str, the task is to check whether all the substrings of length ≥ 2 have the number of vowels at least as… Read More »

## Count of triplets in an array that satisfy the given conditions

Given an array arr[] of N elements, the task is to find the count of triplets (arr[i], arr[j], arr[k]) such that (arr[i] + arr[j] +… Read More »

## Longest Increasing Subsequence using Longest Common Subsequence Algorithm

Given an array arr[] of N integers, the task is to find and print the Longest Increasing Subsequence. Examples: Input: arr[] = {12, 34, 1,… Read More »

## Sum of the digits of square of the given number which has only 1’s as its digits

Given a number represented as a string str consisting of the digit 1 only i.e. 1, 11, 111, …. The task is to find the… Read More »