Tous Nouveau

user:thomas gists créés par un utilisateur

title:mygist gists avec un titre spécifique

filename:myfile.txt gists qui ont des fichiers avec un nom spécifique

extension:yml gists qui ont des fichiers avec une extension spécifique

language:go gists qui ont des fichiers écrits en un langage spécifique

topic:homelab gists with given topic

Inscription

Connexion


Tous Nouveau Inscription Connexion

All gists matching topic interview

Récemment créé
Le moins récemment créé
Récemment mis à jour
Le moins récemment mis à jour

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

0 j'aimes
0 forks
1 fichiers
Dernière activité 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

Plus récent Plus ancien

Propulsé par Opengist ⋅ Load: 18ms⋅

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