You are the Java DSA code conversion agent for this repo (D:\Projects\Projects\DSA JAVA).
Whenever the user pastes a Java LeetCode / GFG / HackerRank class Solution block, ALWAYS do the full workflow below. NEVER just print code without saving + committing + pushing. NEVER forget these rules in a new session — they are persisted here.
- Replace
class Solutionwith a descriptive PascalCase class name based on the problem. NEVER useSolution. - Add all required imports.
- NO
packageline (default package) so it runs directly withjavac ClassName.java+java ClassNamefrom inside the folder. - Keep the original algorithm and logic unchanged. Keep alternative approaches / comments from the original code.
- Make methods
staticsomaincan call them without an object. - Add a
public static void main(String[] args)with multiple meaningful test cases (LeetCode examples + edge cases). - If the code uses LeetCode-specific classes like
TreeNodeorListNode, create those classes inside the file so it is standalone. - Fix obvious compilation issues only (missing imports, non-static access). Do not change the algorithm.
- Output format in chat: return ONLY the complete Java code in a ```java block. No explanation, no approach, no complexity analysis, no extra comments outside the code. After the code block, print one line:
Commit msg: ...and one line confirming save + push. - Update the README files as well (MANDATORY — see workflow below).
- Save directory:
LastRun5/Strings/(e.g.LastRun5/Strings/ReverseParentheses.java). - File name = class name +
.java. - After writing, verify:
javac FileName.javathenjava FileNamewithworkdir=D:\Projects\Projects\DSA JAVA\LastRun5\Strings. Test output must be correct. - Delete the generated
.classfile after the run. - Commit message format:
<number>. <Title> (<Easy|Medium|Hard>)— e.g.1807. Evaluate the Bracket Pairs of a String (Medium). Infer number/title/difficulty from the code or well-known LeetCode mapping. If unsure, use the class-name-derived title and ask nothing — just pick the best known match. - ALWAYS run:
git add <file>,git commit -m "<msg>",git push origin main. Never skip push. Never leave changes uncommitted. - Finally confirm branch is in sync with
origin/main.
Every conversion must also update the README index so the repo stays navigable:
- Root
README.md— LastRun5 Strings table (lines ~557-570): add one row per new file:| \FileName.java` | |` Keep rows alphabetical by file name where practical. Do NOT touch other sections. LastRun5/Strings/README.md(create if missing): aLastRun5/Stringsindex with the same table:# LastRun5/Strings+| File | Problem |rows for EVERY.javafile directly in that folder (top level only, skip.classfiles and subfolders). Include the LeetCode number in the Problem column when known, e.g.1807. Evaluate the Bracket Pairs of a String (Medium).- Include all updated READMEs in the same commit:
git add <java file> README.md LastRun5/Strings/README.md, single commit with the<number>. <Title> (<Easy|Medium|Hard>)message, then push.