当前位置:网站首页>【每日3题(1)】判断国际象棋棋盘中一个格子的颜色
【每日3题(1)】判断国际象棋棋盘中一个格子的颜色
2022-06-29 10:15:00 【程序猿不脱发2】
题目:
给你一个坐标 coordinates ,它是一个字符串,表示国际象棋棋盘中一个格子的坐标。下图是国际象棋棋盘示意图。

如果所给格子的颜色是白色,请你返回 true,如果是黑色,请返回 false 。
给定坐标一定代表国际象棋棋盘上一个存在的格子。坐标第一个字符是字母,第二个字符是数字。
示例 1:
输入:coordinates = “a1”
输出:false
解释:如上图棋盘所示,“a1” 坐标的格子是黑色的,所以返回 false 。
示例 2:
输入:coordinates = “h3”
输出:true
解释:如上图棋盘所示,“h3” 坐标的格子是白色的,所以返回 true 。
示例 3:
输入:coordinates = “c7”
输出:false
提示:
coordinates.length == 2
‘a’ <= coordinates[0] <= ‘h’
‘1’ <= coordinates[1] <= ‘8’
java代码:
class Solution {
public boolean squareIsWhite(String coordinates) {
return (coordinates.charAt(0) + coordinates.charAt(1)) %2>0;
}
}
边栏推荐
- JS post download file
- VI exit exit VIM applicable novice
- 常见电机分类和驱动原理动画[通俗易懂]
- Thoroughly understand JVM Series 7: what is the flow process of objects in the generational model?
- 免费送书啦!畅销书《 OpenCV图像处理入门与实践》一本全搞定
- The necessary operation for those big guys to fly 666 inadvertently at the bash command line terminal
- X-Frame-Options(点击劫持) 网页劫持漏洞
- Using EasyX configuration in clion
- (JS)模仿一个instanceof方法
- 由ASP.NET Core根据路径下载文件异常引发的探究
猜你喜欢

最后的 48 小时!云 XR 专题赛邀你一起绽放精彩,我们赛场见!

极限导论总结

BS-GX-018 基于SSM实现在校学生考试系统

math_ Mathematical expression & deformation of equation equation & accumulation of combined operation skills / means

Free books! The best-selling book "Introduction and practice of OpenCV image processing" has been completed
![[various * * question series] what are OLTP and OLAP?](/img/3f/48b4108d14d40212f678971c1b62bb.png)
[various * * question series] what are OLTP and OLAP?

历史上的今天:马斯克出生;微软推出 Office 365;蔡氏电路的发明者出生
![[FreeRTOS] 08 mutex semaphores and priority inversion](/img/16/9715d5599db6ec107c8001fbd70ae2.png)
[FreeRTOS] 08 mutex semaphores and priority inversion

ModbusTCP协议WIFI无线学习型单路红外模块(圆壳版)

Spark - one to one correspondence between task and partition and detailed explanation of parameters
随机推荐
(JS)筛选出对象中value大于2的key
常见电机分类和驱动原理动画[通俗易懂]
工具箱之 IKVM.NET 项目新进展
BS-GX-018 基于SSM实现在校学生考试系统
USB转RS485串口电路设计「建议收藏」
他98年的,我玩不过他...
(JS)数组去除重复
“AI x 科学计算”进行时,华为昇思 MindSpore 赛题火热开启,等你来!
Creating postgre enterprise database by ArcGIS
The necessary operation for those big guys to fly 666 inadvertently at the bash command line terminal
misc3~7
Excel date and number format processing
The use of variables in shell that you have to be familiar with
内存分配——静态存储区 栈 堆 与static变量
Multi thread communication between client and server (primary version)
Lizuofan, co-founder of nonconvex: Taking quantification as his lifelong career
crypto 1~5
ZABBIX monitors various MySQL indicators
Graduation season · advanced technology Er - workers in the workplace
Interview questions of Tencent automation software test of CSDN salary increase secret script (including answers)