Maximise The Product

Правка en2, от gXa, 2017-05-18 16:16:23

This is one of the interview question.

Given row on N house, each is marked either R or B and each house having some gems.

You have to collect gems from these house with some constraint: You can choose gems from any blue house but you have to choose even number of red house ( either from 2 Red houses or from 4 red houses)

Each time you take gem from one house, you will multiply gems received with gems currently, you have.

You have to choose continuous houses and maximise the product. 

You have to return start point and end point of house (remember this should be continuous ).

I can think of O(N^2) solution but not better than that. So, can someone recommend a better algorithm.
Теги #interview, maximise, product

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский gXa 2017-05-18 16:16:23 4
en1 Английский gXa 2017-05-18 16:15:48 766 Initial revision (published)