Pergunta de entrevista da empresa C3 AI

Implement a graph where only the nodes within a given screen is visible. You will be given screen size, coordinates of the screen edges, coordinates of the graph nodes. Implement a function fetchVisibleNodes to return current visible nodes, and functions to move screen to left, right, up, down. The function fetchVisibleNodes should return the right nodes after moving the graph around. This question had to be done in JavaScript and the interviewer would help you out with the syntax if JS is not your primary language.

Resposta da entrevista

Sigiloso

7 de ago. de 2022

Mostly a brute-force solution. No special tricks or tips. The idea was to keep track of the edge nodes and update the neighbors when the screen is moved.