用html是做班级简介网站,成都建设网站那个好,网站建设邮,wordpress 评论看不到目录
小前言
思路#xff1a;
上代码
lucky ending 小前言
经过漫长的停更周期-----1个月
我决定铁血回归#xff01;#xff01;#xff01; 思路#xff1a;
两层for循环暴力最快了这种小小范围题#xff0c;主要是第一行和第一列的边界处理#xff0c;我分为…目录
小前言
思路
上代码
lucky ending 小前言
经过漫长的停更周期-----1个月
我决定铁血回归 思路
两层for循环暴力最快了这种小小范围题主要是第一行和第一列的边界处理我分为左上角第一行第一列一般情况来处理。对于一般情况的总体判断思路采取当前为X时左边和上边都为 . 那么num1
上代码
class Solution(object):def countBattleships(self, board)::type board: List[List[str]]:rtype: intmlen(board)nlen(board[0])num0for i in range(m):for j in range(n):if i0 and j0 and board[i][j]X:num1continueif i0 and board[i][j]X and board[i][j-1].:num1continueif j0 and board[i][j]X and board[i-1][j].:num1continueif board[i][j]X and board[i-1][j]. and board[i][j-1].:num1return num
lucky ending