Skip to content

feat: add TypeScript solution for Valid Parentheses (practice1) - #196

Merged
Huerte merged 1 commit into
Huerte:mainfrom
painbaba:issue-192-typescript-practice1
Nov 7, 2026
Merged

Huerte merged 1 commit into
Huerte:mainfrom
painbaba:issue-192-typescript-practice1

Conversation

@painbaba

@painbaba painbaba commented Nov 7, 2026

Copy link
Copy Markdown

Summary

First TypeScript solution for the repo, as requested in #192: solutions/typescript/practice1.ts, a port of the existing Python Valid Parentheses solution (solutions/python/practice410.py) so learners can compare the two side by side.

  • Same stack-based algorithm, with TypeScript type annotations on the function signature, the lookup object (Record<string, string>), the stack (string[]), and the test-case list (Array<[string, boolean]>).
  • Includes 9 standalone self-checking cases (same suite as the Python version, including the empty-string and unmatched-open edge cases) — no test framework needed, just node solutions/typescript/practice1.ts.
  • Brief comments explain why a stack matches the "most recent unmatched bracket" rule.

This makes TypeScript the fourth language for this problem alongside Python, JavaScript, and Java.

Related issue

Closes #192

Validation

  • node solutions/typescript/practice1.ts on Windows, Node v24.17.0 (native TypeScript type-stripping): All 9 test cases passed!
  • Repository header validator (python -I scripts/check_solution_headers.py --base upstream/main --head HEAD): passed.

Checklist

  • The solution includes the required problem, source, and note header comment.
  • The file is in the correct solutions/<language>/ folder (solutions/typescript/, new language folder, lowercase) and follows the practice<n> naming convention.
  • I ran the solution and checked that it works.
  • I have kept this pull request focused on one change.

@Huerte
Huerte merged commit 2ef3749 into Huerte:main Nov 7, 2026
1 check passed
@Huerte

Huerte commented Nov 7, 2026

Copy link
Copy Markdown
Owner

@painbaba Hi there! Thanks for the contribution.

download (6)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Be the first! Add a solution in a language this repo doesn't have yet

3 participants