Shortest Path with Direction Switching, XOR Subsequence Enumeration, Majority Element Intervals, and Digit-wise Knapsack

A. Grid Navigation with Direction Toggle Given an n × m grid, start at (1,1) with orientation o = 0. When o = 0, movement is only vertical; when o = 1, only horiznotal. Each move costs 1. At k specified positions, you may flip o (cost 1). Find the minimal cost to reach (n,m). Solution: Model each toggle point as two nodes—one for each orientati ...

Posted on Tue, 20 Oct 2026 16:11:39 +0000 by lhaynes