Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

156
Visualizações
Using DFS to check if I can remove a specific "node"

I'm working on a tile based city builder. Currently the way the data is stored is an array of objects. Within each object, it has information like its location and other tile properties,

State.land = [
  { location: [0, 0] },
  { location: [0, 1] },
  { location: [1, 1] },
  { location: [1, 2] },
  { location: [-1, 0] },
]

The player can click on spots next to existing locations which would push a new object with the location into the land array.

Currently working on a delete method. You can only delete a land if all adjacent lands can reach [0, 0] ([0, 0] is not delete-able)

Im thinking this would be a good way to implement a nice path finding algorithm and DFS was the first that came into mind.

I've only ever implemented DFS while leetcoding but it's been awhile since I last done it. Would DFS be a good option for this problem?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda