Tag Archives: Dynamic Programming

Find minimum possible size of array with given rules for removing elements

Given an array of numbers and a constant k, minimize size of array with following rules for removing elements. Exactly three elements can be removed at one go. The removed three elements must be adjacent in array, i.e., arr[i], arr[i+1], arr[i+2]. And the second element must be k greater than first and third element must… Read More »

Count total number of N digit numbers such that the difference between sum of even and odd digits is 1

Given a number n, we need to count total number of n digit numbers such that the sum of even digits is 1 more than the sum of odd digits. Here even and odd means positions of digits are like array indexes, for exampl, the leftmost (or leading) digit is considered as even digit, next… Read More »