全部 新建

user:thomas 由使用者建立的 Gists

title:mygist Gists 的標題

filename:myfile.txt Gists 的檔案名稱

extension:yml Gists 的副檔名

language:go Gists 的程式語言

topic:homelab gists with given topic

註冊

登錄


全部 新建 註冊 登錄

linkjobai

加入 1794544815

倒序排序 創建
順序排序 創建
倒序排序 更新
順序排序 更新
所有 Gists 1

linkjobai / Design Tic-Tac-Toe in O(1) per Move (LeetCode 348)

0 喜歡
0 分支
1 檔案
最後活躍 1794544815
Interview prep notes
interview

Design Tic-Tac-Toe in O(1) per Move (LeetCode 348)

"Design Tic-Tac-Toe" looks trivial, but the follow-up, "can you check for a winner faster than O(n²) per move?", is what the interviewer is really after.

Naive approach

After each move, scan the move's row, its column and both diagonals: O(n) per move. Fine for 3x3, but the interviewer will push for better on an n x n board.

O(1) idea: running sums

上一頁 下一頁

由 Opengist 提供支持 ⋅ Load: 19ms⋅

繁體中文
Čeština Deutsch English Español Français Magyar Italiano 日本語 Polski Português Русский Türkçe Українська 中文 繁體中文