Find the minimum strength someone must have in the beginning so that he can cross N cells Interview question

0 votes

Problem Statement:

Mustafa wants to cross a dungeon. The dungeon has N cells, and in every cell, there are M monsters. To cross each cell he has to kill one monster, on killing the monster, he loses the strength equal to that of the monster and gains some confidence which adds up to his strength and he proceeds to the next cell. Mustafa can only kill a monster if his strength is greater than or equal to the strength of the monster. Help him find the minimum strength he must have in the beginning so that he can cross N cells.

Input format:

  • First two integers are N and M.
  • N X M matrix represents the energy required to kill the monster in each cell.
  • N X M matrix that represents confidence gained by killing respective monsters.

Testcase:

Input:

3 3
3 2 5
8 9 1
4 7 6
1 1 1
1 1 1
1 1 1

Output:

5

Can someone tell me I can solve this with  Dynamic programming?

May 26, 2022 in Python by Kichu
• 19,050 points
1,903 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Python

+2 votes
2 answers

In a list of dictionaries, how can I find the minimum calue in a common dictionary field.

There are several options. Here is a ...READ MORE

answered Apr 10, 2018 in Python by charlie_brown
• 7,720 points
1,100 views
0 votes
1 answer

How can I find out the index of an element from row and column in Python?

You probably want to use np.ravel_multi_index: [code] import numpy ...READ MORE

answered Apr 16, 2018 in Python by charlie_brown
• 7,720 points
2,051 views
0 votes
1 answer

Can someone explain the behaviour of increment and decrement operators in python

down voteaccepted ++ is not an operator. It is ...READ MORE

answered May 15, 2018 in Python by aryya
• 7,450 points
1,520 views
0 votes
1 answer

How can I find the square of a number in python?

You can use the exponentiation operator or ...READ MORE

answered May 21, 2019 in Python by Mohammad
• 3,230 points
939 views
0 votes
1 answer

How can I raise an exception in Python so that it can later be caught via an except block?

It's pretty simple to raise a query  raise ...READ MORE

answered May 29, 2019 in Python by Umesh
746 views
0 votes
0 answers
0 votes
1 answer

What is the difference between tree depth and height?

To answer your question, you will have ...READ MORE

answered Feb 9, 2022 in Python by Rahul
• 9,670 points
1,393 views
0 votes
1 answer

Competitive Programming Algorithm Sock Drawing Probability Question

Another way to look at the problem ...READ MORE

answered Mar 25, 2022 in Machine Learning by Dev
• 6,000 points
412 views
0 votes
1 answer

Why would anyone use set instead of unordered_set?

Unordered sets must compensate for their O(1) ...READ MORE

answered Jun 1, 2022 in C++ by Damon
• 4,960 points
2,347 views
+1 vote
2 answers

Different data structures in R

The different data types in R are ...READ MORE

answered Aug 26, 2019 in Data Analytics by anonymous
• 33,030 points
1,205 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP