Skip to content

bharg071105/ZebraCrossing-Java-Program

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

ZebraCrossing-Java-Program

Zebra Crossing Traversal - Java Program

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors