[LeetCode]419. Battleships in a Board
来源:互联网 发布:windows xp企业版下载 编辑:程序博客网 时间:2024/05/16 03:00
https://leetcode.com/problems/battleships-in-a-board/?tab=Description
找出连续X(横向或者纵向)的个数
public class Solution { public int countBattleships(char[][] board) { if (board == null || board.length == 0) { return 0; } int res = 0; for (int i = 0; i < board.length; i++) { for (int j = 0; j < board[0].length; j++) { if (board[i][j] == '.') { continue; } if (i > 0 && board[i - 1][j] == 'X') { continue; } if (j > 0 && board[i][j - 1] == 'X') { continue; } res++; } } return res; }}
0 0
- 【leetcode】419. Battleships in a Board【E】
- Leetcode题解:419. Battleships in a Board
- 419. [LeetCode]Battleships in a Board
- LeetCode 419. Battleships in a Board
- leetcode 419. Battleships in a Board
- LeetCode笔记:419. Battleships in a Board
- LeetCode 419. Battleships in a Board
- [leetcode]419. Battleships in a Board
- 【LeetCode】 419. Battleships in a Board
- LeetCode--419. Battleships in a Board
- LeetCode 419. Battleships in a Board
- [leetcode]419. Battleships in a Board
- Leetcode-419. Battleships in a Board
- 【LeetCode】419. Battleships in a Board
- LeetCode:419. Battleships in a Board
- [LeetCode]419. Battleships in a Board
- [LeetCode]419. Battleships in a Board
- 【LeetCode】419. Battleships in a Board
- 06-线程的主动切换
- android key事件分发与焦点事件的传递
- tomcat源码阅读(一)——环境搭建
- setBackgroundResource设置背景导致padding失效
- 关于storyboard
- [LeetCode]419. Battleships in a Board
- adb 调试命令
- 解决MATLAB报错“错误使用 mtimesx_build”
- 左式堆的合并
- fragment中嵌套fragment时出现空白页问题解决
- 服务器微信支付接口笔记-(与app端对接)
- webx.xml装载顺序与PropertyPlaceholderConfigurer的应用
- 第三周作业:位运算
- 软件下载