Project Description This project solves the Zebra Crossing Traversal problem using Java.
A traveler starts at index 0 of a zebra crossing represented by a string of black and white blocks ('0' and '1'). The program finds the farthest block reachable within the allowed jump limit while following the alternating color rule.
Problem Statement
- The traveler starts at position 0.
- Maximum jump distance is K blocks.
- A move is valid only if the destination block has a different color from the current block.
- The program finds the farthest reachable index.
Technologies Used
- Java
- IntelliJ IDEA
Concepts Used
- Greedy Logic
- Strings
- Loops
- Conditional Statements
- Input Handling using Scanner
Input Format text id="bzck8m" N K String of 0s and 1s
Example: text id="gw4uxl" 8 3 01011010
OutpuT text id="wyg20k" Maximum Reachable Block Index: 3
Source Code Features
- Efficient input handling
- Valid move checking
- Maximum reachable index calculation
- Simple and optimized Java implementation