+ [task#128767] add calculation logic for maxLeft and minRight for the getMaxLeftAndMinRight.
This commit is contained in:
@@ -175,7 +175,19 @@ function getMaxLeftAndMinRight(rows, start, h)
|
||||
const rowLength = rows[Math.min(start + h - 1, rows.length - 1)]?.length || 0;
|
||||
let left = rows[start][0][0] || 0;
|
||||
let right = rowLength ? rows[Math.min(start + h - 1, rows.length - 1)][rowLength - 1][1] : 0;
|
||||
for(let i = start; i < start + h; i++)
|
||||
{
|
||||
if(rows[i])
|
||||
{
|
||||
const rowData = rows[i];
|
||||
const flattenedRow = flattenData(rowData);
|
||||
const maxLeft = flattenedRow.reduce((max, item) => item[0] > max ? item[0] : max, -Infinity);
|
||||
const minRight = flattenedRow.reduce((min, item) => item[1] < min ? item[1] : min, Infinity);
|
||||
|
||||
left = Math.max(left, maxLeft);
|
||||
right = Math.min(right, minRight);
|
||||
}
|
||||
}
|
||||
return {left, right};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user