Introducci贸n

1

驴Ya tomaste el Curso Avanzado de Algoritmos: Patrones de Arrays y Strings?

Lista Enlazada

2

Estructura de datos: Lista Enlazada

3

Programando listas enlazadas con Java

4

C贸mo Invertir una Lista Enlazada

5

Odd Even Linked List: an谩lisis del problema

6

Soluci贸n de Odd Even Linked List

7

Playground: Odd Even Liked List

8

Programando Odd Even Linked List con C++

9

Linked List Cycle: an谩lisis del problema

10

Soluci贸n de Linked List Cycle

11

Playground: Linked List Cycle

12

Programando Linked List Cycle con Python

13

Palindrome Linked List: an谩lisis del problema

14

Soluci贸n de Palindrome Linked List

15

Playground: Palindrome Linked List

16

Programando Palindrome Linked List con Java

17

Reorder List: an谩lisis del problema

18

Soluci贸n de Reorder List

19

Programando Reorder List con JavaScript

20

Playground: Reorder List Without Repeated Values

21

Reto: LRU Cach茅

22

Ejercicios recomendados de Lista Enlazada

23

Ejercicios resueltos de Lista Enlazada

Pilas y colas

24

Estructura de datos: Pilas y Colas

25

Par茅ntesis V谩lido: an谩lisis del problema

26

Soluci贸n de Par茅ntesis V谩lido

27

Playground: Par茅ntesis V谩lido

28

Programando Par茅ntesis V谩lido con C++

29

Ejercicios recomendados de Pilas

Colas de prioridad

30

Estructura de datos: Colas de Prioridad

31

K Closest Points to Origin: an谩lisis del problema

32

Soluci贸n de K Closest Points to Origin

33

Playground: K Closest Points to Origin

34

Programando K Closest Points to Origin con Python

35

Reorganize String: an谩lisis del problema

36

Soluci贸n de Reorganize String

37

Playground: Reorganize String

38

Programando Reorganize String con Python

39

Ejercicios recomendados de Colas de prioridad

40

Ejercicios resueltos de Colas de prioridad

Pr贸ximos pasos

41

Toma el Curso Avanzado de Algoritmos: Grafos y 脕rboles

Aprovecha el precio especial y haz tu profesi贸n a prueba de IA

Antes: $249

Currency
$209
Suscr铆bete

Termina en:

2 D铆as
12 Hrs
7 Min
58 Seg

Ejercicios resueltos de Colas de prioridad

40/41

Reading

Solved Priority Queuing Exercises

Task Organizer

...

Register or log in to read the rest of the content.

Contributions 1

Questions 1

Sort by:

Want to see more contributions, questions and answers from the community?

Dejo como resolvi el ejercicio de Car Pooling:

def car_pooling(trips: list[list[int]], capacity: int) -> bool:
    trips.sort(key=lambda x: x[1]) # Ordenamos por inicios de viajes
    ongoing_trips = [] # heap para registrar los viajes que aceptas [[kilometroFinal, noPasajeros]]
    kilometer = 0

    while trips:

        while ongoing_trips and kilometer == ongoing_trips[0][0]:
            capacity += ongoing_trips[0][1]
            heapq.heappop(ongoing_trips)

        while trips and kilometer == trips[0][1]:
            if capacity >= trips[0][0]:
                heapq.heappush(ongoing_trips, [trips[0][2], trips[0][0]])
                capacity -= trips[0][0]
                trips.pop(0) # Eliminamos de la lista el viaje tomado
            else:
                return False # No se pudo aceptar un viaje
            
        kilometer += 1
    return True