Skip to content

Instantly share code, notes, and snippets.

View shivanipandey9451-cloud's full-sized avatar

shivanipandey9451-cloud

View GitHub Profile
@shivanipandey9451-cloud
shivanipandey9451-cloud / restore_instructions.py
Created November 1, 2025 09:25
“Minimum cut-and-insert operations to restore instruction order”
#!/usr/bin/env python3
import sys
from collections import deque
def read_input():
data = [line.rstrip("\n") for line in sys.stdin.readlines()]
# remove leading/trailing empty lines
while data and data[0].strip()=="":
data.pop(0)
if not data: