Skip to content

[Feature]: Add Java code support to Sliding Window Visualizer #803

Description

@tazmeen24

Problem or limitation

  • SlidingWindowVisualizer.jsx only supports executable code examples in JavaScript and Python.
  • Java support is missing despite AlgoScope advertising Java, C++, Python, and JavaScript support.
  • Learners using Java have no code reference for the sliding window visualizer.
  • Missing Java implementation affects:
    • Max Sum of Size K
    • Longest Unique Substring
    • Smallest Subarray ≥ Target

Proposed solution

Add a java entry to the code object for all six approach configs (3 problems × brute force + sliding window), following the existing js/py pattern of { src: [...], map: {...} }. Specifically:

  • Add Java source line arrays with correct map line-number references for step-highlighting (each language has its own map since line counts differ)
  • Extend the tokenize() syntax highlighter with a Java-aware regex (keywords like public, static, void, int, class, new, Integer.MAX_VALUE, HashSet, etc.)
  • Add 'java' to the language toggle button list (currently ['js', 'py'])
  • Update the code panel filename label to show .java when Java is selected

Alternatives considered

N/A

Use case

Students working through algorithm patterns in a Java-based course or interview prep track (many DSA courses and interviews are Java-first) can follow the same step-by-step animation and see the equivalent Java code highlighted in sync, instead of having to mentally translate from the JS or Python shown.

Additional context

N/A

Metadata

Metadata

Assignees

Labels

GSSoCOfficial issue for GSSoC contributors

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions