• Skip to main content
  • Skip to footer

GO ALGORITHMS

Soluciones de lógica con Golang

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

Stacks

Valid Parenthesis Expression

Easy

Given a string representing an expression of parentheses containing the characters '(', ')', '[', ']', '{', or '}', determine if the expression forms a valid sequence of parentheses.

A sequence of parentheses is valid if every opening parenthesis has a corresponding closing parenthesis, and no closing parenthesis appears before its matching opening parenthesis.

Example 1:

Input: s = '([]{})'
Output: True

Example 2:

Input: s = '([]{)}'
Output: False

Explanation: The '(' parenthesis is closed before its nested '{' parenthesis is closed.

Next Largest Number to the Right

Medium

Given an integer array nums, return an output array res where, for each value nums[i], res[i] is the first number to the right that’s larger than nums[i]. If no larger number exists to the right of nums[i], set res[i] to ‐1.

Example:

Input: nums = [5, 2, 4, 6, 1]
Output: [6, 4, 6, -1, -1]

Evaluate Expression

Hard

Given a string representing a mathematical expression containing integers, parentheses, addition, and subtraction operators, evaluate and return the result of the expression.

Example:

Input: s = '18-(7+(2-4))'
Output: 13

Repeated Removal of Adjacent Duplicates

Easy

Given a string, continually perform the following operation: remove a pair of adjacent duplicates from the string. Continue performing this operation until the string no longer contains pairs of adjacent duplicates. Return the final string.

Example 1:

Input: s = 'aacabba'
Output: 'c'

Example 2:

Input: s = 'aaa'
Output: 'a'

Implement a Queue using Stacks

Medium

Implement a queue using the stack data structure. Include the following functions:

  • enqueue(x: int) -> None: adds x to the end of the queue.
  • dequeue() -> int: removes and returns the element from the front of the queue.
  • peek() -> int: returns the front element of the queue.

You may not use any other data structures to implement the queue.

Example

Input: [enqueue(1), enqueue(2), dequeue(), enqueue(3), peek()]
Output: [1, 2]

Constraints:

  • The dequeue and peek operations will only be called on a non-empty queue.

Maximums of Sliding Window

Hard

There’s a sliding window of size k that slides through an integer array from left to right. Create a new array that records the largest number found in each window as it slides through.

Example:

Input: nums = [3, 2, 4, 1, 2, 1, 1], k = 4
Output: [4, 4, 4, 2]

Footer

Primeros con algoritmia

Amazon Interview | Asteroid Collision | Data Structures & Algorithms

Algoritmos por dificultad en Go

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

Algoritmos fáciles con Go

  • Amazon Interview | Asteroid Collision | Data Structures & Algorithms
  • Cifrado César
  • Math And Geometry
  • Bit Manipulation
  • Básicas
  • Más usadas
  • Complejas

Algoritmos intemedios con Go

  • Amazon Interview | Asteroid Collision | Data Structures & Algorithms
  • Cifrado César

Algoritmos avanzados con Go

  • Amazon Interview | Asteroid Collision | Data Structures & Algorithms
  • Cifrado César

Copyright © 2026 · Log in