开发者

least generator I need, a leetcode-like programming problem [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.

Want to improve this question? Add details and clarify the problem by editing this post.

Closed 11 hours ago.

Improve this question

Suppose each machine needs at least one generator next to it. Write a function to print out the least generators I need given an input row.

At first I think this question is easy to solve if I write a lot of "If-else" clauses. But I cannot find out how to think this question in a structured way.


Input1: row = "MIIM". Here "M" refers machine, "I" refers interval. Each interval can contain one generator.

Output1: 2

Two generators needed for two machines.


Inp开发者_运维技巧ut2: row = "IMIMI".

Output2: 1

Two machines can share one generator.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜