I have to admit that I've not been able to solve this task and I have downloaded the solution to see the logic of it.
I'd my own idea about how to solve it on a paper but I was not able to get it implemented.
Said that I'm not sure that the solution given by CODEGYM is right.
Here are my doubts.
* The first issue is that when arr[i][j] is copied into a[i][j] the limit value of j, shouldn't it be a[0].length?
* Then the point 2 of conditions said that the rectangles do not touch or overlap. T
Let's imagine that there's a rectangle with the following limits [0,0] [0,2] / [2,0] [2,2]. To me and according to the condition no 1 should be counted from [0,3] to [2,3] and from [2,0] to [3,2]. Am I right?
[0,0] [0,1] [0,2] [0,3]
[1,0] [1,1] [1,2] [1,3]
[2,0] [2,1] 2,2] [2,3]
[3,0] [3,1] [3,2] [3,3]
* a1 and a2 array are square arrays so the x length and the y length have the same value. Lets try with something like
{1, 1, 0, 0, 1, 1},
{1, 1, 0, 1, 0, 0},
{1, 1, 0, 0, 1, 0},
{0, 0, 0, 1, 1, 1},
{1, 1, 0, 1, 1, 0}
What should be the result? 6?
Task 2026 - Rectangle algorithms
Comments (3)
- Popular
- New
- Old
You must be signed in to leave a comment
Lisa L
19 May 2022, 11:48
afair the conditions said that the rectangles do not touch or overlap. So you can be sure that the validator will not test examples similar to yours. At least I coded my solution with that requirements in mind an it validated.
0
LuisRC
19 May 2022, 17:24
Does it mean that that I misunderstood the conditions and what they actually mean is that in the array there's no touching or overlapping rectangles? 😖😖
0
Lisa L
19 May 2022, 19:27
Happens all the time... at least I always missunderstand what they want from me 😜🤪
0