恒美微站 Logo 恒美微站
  • 首页
  • 关于我们
  • 建站服务
  • 主题模板
  • 案例展示
  • 资讯中心
  • 联系我们

LeetCode //C - 1275. Find Winner on a Tic Tac Toe Game

  • 首页
  • 资讯中心
  • /
  • LeetCode //C - 1275. Find Winner on a Tic Tac Toe Game

相关资讯

@gitbook/react-math:KaTeX 优先、MathJax 兜底的 React 数学公式渲染组件 2026/10/1 2:32:29
Asp.net MVC4企业级源码实战:CMS+CRM+OA+MSSQL跑通与避坑指南 2026/10/1 2:32:29
VMD-Attention-LSTM做时间序列预测:分解+注意力如何降低误差 2026/10/1 2:27:29

最新资讯

知识蒸馏实战:本科毕设如何将人脸关键点检测模型压缩到2MB
WSL2安装与Linux学习环境搭建:从零开始的Windows开发实践
WSL2从入门到实战:Windows下Linux环境搭建与Docker配置指南
IEEE 802.11a OFDM物理层仿真:从参数到SDR验证
知识蒸馏实战:本科毕设人脸关键点小模型CPU实时方案
Python数据分析实战:300行代码分析数据分析师岗位要求与薪资

今日推荐

我发现了一个新思路:用 Remotion + Claude Code 像写代码一样自动化生成短视频
Windows下 Codex 中 Chrome 和 Computer Use 插件不可用问题排查及解决参考方式:TaoToken 统一 Key 配置与验证
2026 大模型集体涨价:用 Python 做企业 Token 成本测算与选型避坑(附配置)

本周热门

从像素到笔画:srt-whiteboard-animation骨架笔迹追踪实现(Zhang-Suen细化+8邻接追踪)
网站建设的英语怎么说?别只背单词,看完这套安全完整流程才敢上线
新手入门看这篇:建设网站加盟避坑指南与SEO实操

本月精选

我发现了一个新思路:用 Remotion + Claude Code 像写代码一样自动化生成短视频
Windows下 Codex 中 Chrome 和 Computer Use 插件不可用问题排查及解决参考方式:TaoToken 统一 Key 配置与验证
2026 大模型集体涨价:用 Python 做企业 Token 成本测算与选型避坑(附配置)

LeetCode //C - 1275. Find Winner on a Tic Tac Toe Game

发布时间:2026/10/1 2:32:29
LeetCode //C - 1275. Find Winner on a Tic Tac Toe Game 1275. Find Winner on a Tic Tac Toe GameTic-tac-toe is played by two players A and B on a 3 x 3 grid. The rules of Tic-Tac-Toe are:Players take turns placing characters into empty squares ’ .The first player A always places ‘X’ characters, while the second player B always places ‘O’ characters.‘X’ and ‘O’ characters are always placed into empty squares, never on filled ones.The game ends when there are three of the same (non-empty) character filling any row, column, or diagonal.The game also ends if all squares are non-empty.No more moves can be played if the game is over.Given a 2D integer array moves wherem o v e s [ i ] [ r o w i , c o l i ] moves[i] [row_i, col_i]moves[i][rowi​,coli​]indicates that thei t h i^{th}ithmove will be played ong r i d [ r o w i ] [ c o l i ] grid[row_i][col_i]grid[rowi​][coli​]. return the winner of the game if it exists (A or B). In case the game ends in a draw return “Draw”. If there are still movements to play return “Pending”.You can assume that moves is valid (i.e., it follows the rules of Tic-Tac-Toe), the grid is initially empty, and A will play first.Example 1:Input:moves [[0,0],[2,0],[1,1],[2,1],[2,2]]Output:“A”Explanation:A wins, they always play first.Example 2:Input:moves [[0,0],[1,1],[0,1],[0,2],[1,0],[2,0]]Output:“B”Explanation:TB wins.Example 3:Input:moves [[0,0],[1,1],[2,0],[1,0],[1,2],[2,1],[0,1],[0,2],[2,2]]Output:“Draw”Explanation:The game ends in a draw since there are no moves to make.Constraints:1 moves.length 9moves[i].length 20 r o w i , c o l i 2 0 row_i, col_i 20rowi​,coli​2There are no repeated elements on moves.moves follow the rules of tic tac toe.From: LeetCodeLink: 1275. Find Winner on a Tic Tac Toe GameSolution:Ideas:put A as 1, B as -1.If any row, column, or diagonal sums to 3, A wins.If it sums to -3, B wins.Code:char*tictactoe(int**moves,intmovesSize,int*movesColSize){intboard[3][3]{0};// A 1, B -1for(inti0;imovesSize;i){intrmoves[i][0];intcmoves[i][1];board[r][c](i%20)?1:-1;}for(inti0;i3;i){introwboard[i][0]board[i][1]board[i][2];intcolboard[0][i]board[1][i]board[2][i];if(row3||col3)returnA;if(row-3||col-3)returnB;}intdiag1board[0][0]board[1][1]board[2][2];intdiag2board[0][2]board[1][1]board[2][0];if(diag13||diag23)returnA;if(diag1-3||diag2-3)returnB;if(movesSize9)returnDraw;returnPending;}

关于恒美微站

恒美微站专注于为个体商户、工作室提供极简自助建站服务,让每个人都能轻松拥有专业网站。

快速链接

  • 关于我们
  • 建站服务
  • 主题模板
  • 案例展示
  • 资讯中心

服务项目

  • 可视化建站
  • 拖拽编辑
  • 主题定制
  • SEO 优化
  • 网站托管

联系方式

  • 📍 地址:北京市朝阳区建国路 88 号
  • 📞 电话:400-888-8888
  • ✉️ 邮箱:info@hmyw.cn
  • 🕐 时间:周一至周日 9:00-18:00

© 2024 恒美微站 hmyw.cn 版权所有 | 京 ICP 备 12345678 号