Suppose we have 2d array A (n by n) and string S. Each cell of array can contain at most one char. Each character of the string can assign only one cell. The two consecutive characters on the string must be positioned to the neighboring cell of the grid(horizontal or vertical NOT DIAGONAL). Pair of ’1’s that are not consecutive characters of the string but are assigned to neighboring nodes of the grid are said to be in contact. For example S=10010110. The max number of contact in this string is 2. Can someone help me. IDN how to approach this problem
Asked
Active
Viewed 41 times
0
-
1Welcome to MSE. You'll get a lot more help if you show that you have made a real effort to solve the problem yourself, even if you haven't made much progress. What are your thoughts? What have you tried? How far could you get? Where are you stuck? This question will likely be closed if you don't add more context. Please respond by editing the question body. Clarifications don't belong in the comments. – saulspatz May 08 '21 at 22:29
-
Looks like the max is 2 (not 1) for your example. – RobPratt May 08 '21 at 22:35
-
Absolutely. Max contact number for this example is 2. I can find max number of contact now but we should also show result matrix. I dont know how to show resuting matrix. Should i try every possibility or is there any easy way? – Mastan Abdulkhaligli May 09 '21 at 09:46