• Skip to main content
  • Skip to footer

Ghoper logic

Algoritmos y lógica con Golang

  • Fácil
  • Intermedio
  • Avanzado
  • Todos
  • GitHub

Amazon Interview | Asteroid Collision | Data Structures & Algorithms

Problem Statement

We are given an array asteroids of integers representing asteroids in a row. The indices of the asteroid in the array represent their relative position in space.

For each asteroid, the absolute value represents its size, and the sign represents its direction (positive meaning right, negative meaning left). Each asteroid moves at the same speed.

Find out the state of the asteroids after all collisions. If two asteroids meet, the smaller one will explode. If both are the same size, both will explode. Two asteroids moving in the same direction will never meet.

Input: asteroids =  [5,10,-5]
Output: [5,10]

Footer

Primeros con algoritmia

Algoritmo de Floyd

Algoritmos por dificultad en Go

  • Fácil
  • Intermedio
  • Avanzado
  • Todos
  • GitHub

Cada sábado estudio y juego con un algoritmo, y se me ocurrió compartir las notas notas para me obligarme a escribir mejor y así  empece a escribir en 2021.

Ahora puedes resolverlos con IA, pero lo hago por curiosidad!

Algoritmos fáciles con Go

  • Algoritmo de Floyd
  • In-Place
  • Amazon Interview | Asteroid Collision | Data Structures & Algorithms
  • Cifrado César
  • Básicas
  • Más usadas
  • Complejas

Algoritmos intemedios con Go

  • Algoritmo de Floyd
  • In-Place

Algoritmos avanzados con Go

  • Algoritmo de Floyd
  • In-Place

Copyright © 2026 · Log in