leetcode419
public class Solution {
public int CountBattleships(char[,] board) {
var row = board.GetLength();//3行
var col = board.GetLength();//4列 int count = ;
for (int i = ; i < row; i++)
{
for (int j = ; j < col; j++)
{
if (board[i, j] == 'X' && (i == || board[i - , j] != 'X') && (j == || board[i, j - ] != 'X'))
{
count++;
}
}
}
return count;
}
}
https://leetcode.com/problems/battleships-in-a-board/#/description
leetcode419的更多相关文章
- [Swift]LeetCode419. 甲板上的战舰 | Battleships in a Board
Given an 2D board, count how many battleships are in it. The battleships are represented with 'X's, ...
随机推荐
- html(对php也有效)页面自动刷新和跳转(简单版本)
<html> <head><title>html页面自动刷新和跳转</title><meta http-equiv="Refres ...
- 新的开源java反汇编程序Procyon
wiki:https://bitbucket.org/mstrobel/procyon/wiki/Java%20Decompiler 由于jd好多年没更新了,今天找到这个新的开源反汇编,很不错 分享一 ...
- appium-java,连接真机启动微信
1.启动appium 2.设置信息 3.设置IP和端口 4.appium连接手机,微信中打开debugx5.qq.com,信息->TBS settings->是否打开TBS内核Insper ...
- HDU - 5942 :Just a Math Problem (莫比乌斯)
题意:略. 思路:问题转化为1到N,他们的满足mu[d]!=0的因子d个数. 即1到N的因子的莫比乌斯系数平方和. (经验:累加符号是累加的个数,我们把常数提到前面,然后用杜教筛累加个数即可. ht ...
- 20179223《Linux内核原理与分析》第三周学习笔记
测试3的实验: 1. 用gcc -g编译vi输入的代码 2. 在main函数中设置一个行断点 3. 在main函数增加一个空循环,循环次数为自己学号后4位,设置一个约为学号一半的条件断点 4. 提交调 ...
- VS2013下的64位与32位程序配置
VS2013下的64位与32位程序配置 在Windows 7 64bit和Visual Studio 2013下生成64位程序. 新建一个Visual Studio Win32 Console项目 ...
- webpack 简单使用
备注: 使用yarn 结合npm 模块进行简单项目开发 1. 安装 yarn init yarn add webpack --dev yarn global add live-server 2. 添 ...
- cockroachdb 安装试用(单机伪分布式)
1. 下载 以下地址,选择对应的操作系统版本即可 https://www.cockroachlabs.com/docs/stable/install-cockroachdb.html 2. 启动 // ...
- fail2ban的介绍
fail2ban的介绍 http://www.jb51.net/article/48591.htm http://lilinji.blog.51cto.com/5441000/1784726 fail ...
- 关于ng-class,ng-style的用法
ng-class的使用几种方式 (1):利用双向数据绑定(className根据chang2的值去匹配类) <div class="{{className}}">... ...