Tutti Nuovi

user:thomas utente che ha creato il gist

title:mygist titolo del gist

filename:myfile.txt nome di file nel gist

extension:yml estensione del file nel gist

language:go linguaggio del file nel gist

topic:homelab gists with given topic

Registrati

Entra


Tutti Nuovi Registrati Entra

linkjobai

Unito 1794544815

Più recente creazione
Meno recente creazione
Più recente aggiornamento
Meno recente aggiornamento
Tutti i gists 1

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

0 mi piace
0 forks
1 files
Ultima volta attivo 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

Più nuovi Più vecchi

Creato da Opengist ⋅ Load: 20ms⋅

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