Solved LeetCode program · 765 of 1,000
#1001 · Grid Illumination
Original English source
The lamp rows is a list of 0 and 4. The lamp columns is a list of 0 and 4. The lit is a list of 1 and 1. The query rows is a list of 1 and 1. The query columns is a list of 1 and 0. The answers is an empty list of whole numbers.
For every query from 0 to 1.
The target row is item query of query rows. The target column is item query of query columns. The glowing is 0.
For every lamp from 0 to 1.
If item lamp of lit is 1 and item lamp of lamp rows is target row, set glowing to 1. If item lamp of lit is 1 and item lamp of lamp columns is target column, set glowing to 1. The row gap is the absolute value of (item lamp of lamp rows minus target row). The column gap is the absolute value of (item lamp of lamp columns minus target column). If item lamp of lit is 1 and row gap is column gap, set glowing to 1. If item lamp of lit is 1 and row gap is at most 1 and column gap is at most 1, set item lamp of lit to 0. If lamp is 1, Place glowing into answers.
The line is empty text.
For each answer in answers.
If the length of line is more than 0, Place "," into line. Place format whole number answer as text into line.
Show line.
Expected stdout
1,0