当前位置:首页|资讯

GFG 145 find the Enemies

作者:您是打尖儿还是住店呢发布时间:2024-10-16

There are k enemies (numbered from 0 to k-1) in n x m grid. Geekina has arrays col and count.

The value col[i] represents the column of the ith enemy, while count[j] denotes the count of

enemies in the jth row. It is ensured that for any two enemies x and y with x < y, row[x] <= row[y].


Return the grid with enemies, marking cells without enemies as -1.


Example 1:


Input:

n = 3

m = 3

k = 3

col = {0, 0, 1}

count = {1, 1, 1}

Output:

{{0, -1, -1},

{1, -1, -1},

{-1, 2, -1}}

Explanation:

The  rst row should have 1 enemy because count[0] = 1, the enemy 0 should be 

placed at row 0 and column 0 of the grid.

The second row should have 1 enemy because count[1] = 1, the enemy 1 should be 

placed at row 1 and column 0 of the grid.

The third row should have 1 enemy because count[2] = 1, the enemy 2 should be 

placed at row 2 and column 1 of the grid.

-----

构造题目,找到敌人的数量即可。我用数组来模拟,然后放到list中的。没想到还能过,,,




Copyright © 2024 aigcdaily.cn  北京智识时代科技有限公司  版权所有  京ICP备2023006237号-1