Category Archives: Algorithm

Digit DP | Introduction

Prerequisite : How to solve a Dynamic Programming Problem ? There are many types of problems that ask to count the number of integers ‘x‘ between two integers say ‘a‘ and ‘b‘ such that x satisfies a specific property that can be related to its digits. So, if we say G(x) tells the number of… Read More »

Find the next identical calendar year

You are given an year Y, find the next identical calendar year to Y. Examples: Input : 2017 Output : 2023 Input : 2018 Output : 2029 An year x is identical to a given previous year y if following two conditions are satisfied. x starts with same day as y. If y is leap… Read More »

Minimum block jumps to reach destination

Given N lines and one starting point and destination point in 2-dimensional space. These N lines divide the space into some blocks. We need to print the minimum number of jumps to reach destination point from starting point. We can jump from one block to other block only if they share a side. Examples: Input… Read More »