Maximize the number of magical gems by passing through array of house

Problem There was a thief, he has to pass through colored house - which can be red or blue, and contain 0 or more gems. The property of these gems is they multiply the previous gems by the current gems in the house. The houses are in array and thief can only visit once to steal the gems, with the goal of maximizing the gems. Find the range of house where he can maximize the gems in such a way that number of red houses are even. [Read More]

Number of steps required to convert string 1 to string2 when only bring character to first index operation is giving

Problem Given 2 strings - s1 and s2, when only 1 operation is allowed - Moving character at a time but only to the first position. Example Example 1 Input s1 = abcd s2 = bacd Output Ans = 1 Reason, just move b forward and we get it. Example 2 Input A = (a)b(cd)e(f)g(hij) B = ahdjcifbeg Output Ans =7 Explanation A = (a)b(cd)e(f)g(hij) B = ahdjcifbeg Characters b,e,g are in the order, rest characters have to brought first. [Read More]

Find the least wastage in cutting the Trees?

Problem You are given n Trees with their heights in an array. and you are given a value k units , that much wood you need to collect. You can have an axe of any height you want but you can use only 1 axe when you choose. Assume height to be integral value. Solution So, if height of the tree is H, and you cut it at height X from the ground then H-X will be used will be used. [Read More]