Todos Nuevo

user:thomas gists creados por el usuario

title:mygist gists con el título indicado

filename:myfile.txt gists que contienen archivos con el nombre indicado

extension:yml gists que contienen archivos con la extensión indicada

language:go gists que contienen archivos con el lenguaje indicado

topic:homelab gists with given topic

Registrarse

Iniciar sesión


Todos Nuevo Registrarse Iniciar sesión

linkjobai

Unido 1794544815

Recientemente creado
Menos reciente creado
Recientemente actualizado
Menos reciente actualizado
Todos los gists 1

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

0 gustos
0 bifurcaciones
1 archivos
Última actividad 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

Siguiente Anterior

Desarrollado por Opengist ⋅ Load: 21ms⋅

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