Question: You are given an ' m x n ' matrix where each cell represents either an alphabetical character ( denoted by ' a ' to
You are given an m x n matrix where each cell represents either an alphabetical character denoted by a to z or a wildcard character denoted by
You have a starting amount of energy, E
You are allowed to move only in these directions right, left, down, or up Each move costs unit of energy.
A
Your task is to search for the sequence of characters from the given character array in the target D matrix while managing your energy.
You can only move to adjacent cells if you have sufficient energy.
You can match wildcard character to any character in the given input array.
Write a function 'searchwithenergy' that takes the sequence of characters, matrix, and the initial energy as input. And returns either or bases on the following constraints
If you run out of energy before searching is completed, return
If you aren't able to find the given sequence of characters,return
If you can find the given sequence of characters, return
You can use a cell in D matrix for matching only once.
You can't use the same cell for matching different positionsfrom given character sequence. However, you can movethrough already matched cell.
Additional Constraints:
n m
energy
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
