Dynamic Programming Made Easy

Coming Soon

Read more...

Palindromic Partitioning

Problem Statement Given an integer array,  partitioning the array is said to be a palindrome partitioning if every subarray of the partition is a palindrome. For example, 1 | 2 2 2 | 23 | 4 is a palindrome partitioning of array { 1,2,2,2,23,4 }. You have to find out the fewest cuts needed for palindrome partitioning of a…

Read more...

MyGate Interview Experience. [SET-1]

Round 1 – Written They(MyGate) had printed questions on paper there were multiple sets of those like we used to have in School Exam. Each paper has 3 questions and We need to write working code on laptop and mail to the recruiter. Out of 4 questions – 1 Easy, 1 Medium and 2 hard…

Read more...

Hamiltonian Graph – Paper Boy Problem

Shyam needs to distribute newspaper to all the houses while following these rules: He can start from any vertex. When he is on a vertex, he must distribute the newspaper. You can only travel to a vertex that is connected to the current vertex by an edge. You cannot visit a vertex which is already…

Read more...

String to Integer (atoi)

Implement atoi which converts a string to an integer. The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this character, takes an optional initial plus or minus sign followed by as many numerical digits as possible, and interprets them as a numerical value. The string can contain…

Read more...

Maximum Difference in an Array

You are given an array of integers and must compute the maximum difference between any item and any lower indexed smaller item for the possible pairs, i.e., for a given array a find the maximum value of a[j] – a[i] for all i, j where 0 <= i < j < n and a[i] <…

Read more...

Counting Valleys – HackerRank

Gary is an avid hiker. He tracks his hikes meticulously, paying close attention to small details like topography. During his last hike he took exactly steps. For every step he took, he noted if it was an uphill, , or a downhill, step. Gary’s hikes start and end at sea level and each step up…

Read more...

Alice and his candy

Alice is a kindergarten teacher. She wants to give some candies to children in her class. All the children sit in a line and each of them has a rating score according to his or her performance in the class. Alice wants to give at least 1 candy to each child. If two children sit next to…

Read more...

Trailing Zeroes in Factorial of a Number – FCTRL – SPOJ

Now we can approach it in 2 ways – the first approach is to calculate factorial of a number and then calculate the number of trailing zeros from the result. But for any value greater than 12 we will see integer exceed. So let’s go with the second approach and Find a relation between number and…

Read more...

SPOJ – FCTRL – Factorial

The most important part of a GSM network is so called Base Transceiver Station (BTS). These transceivers form the areas called cells (this term gave the name to the cellular phone) and every phone connects to the BTS with the strongest signal (in a little-simplified view). Of course, BTSes need some attention and technicians need…

Read more...
Bitnami