["B", "C", "C", "C", "C", "B", "B", "C", "A", "A"],
["B", "A", "C", "B", "B", "A", "B", "B", "A", "A"],
["B", "C", "B", "C", "A", "A", "A", "B", "C", "B"],
["B", "B", "B", "A", "C", "B", "A", "C", "B", "A"],
["A", "A", "A", "C", "A", "C", "C", "B", "A", "C"],
["A", "B", "B", "A", "A", "C", "B", "C", "C", "C"],
["C", "B", "A", "A", "C", "B", "B", "C", "A", "A"]
We need to find the largest rectangle with one value in this arrangement First, you want to find the farthest value of the same alphabet in a row and compare it vertically. Please give me some advice I would appreciate it if you could let me know if you have a good approach to this problem!
javascript algorithm
To find the furthest value of an element in an array, you can look at the array as a stack and pop it one by one. So if you compare the elements behind you and find the same thing, it's a long way off.
And how about comparing the longitudinal values by taking the transposition matrix for the matrix above and finding it in the array above?
© 2024 OneMinuteCode. All rights reserved.