Skip to content

Add Python solution for Count Triplets (practice409) - #161

Merged
Huerte merged 1 commit into
Huerte:mainfrom
codekongdev:feat/158-count-triplets
Nov 4, 2026
Merged

Huerte merged 1 commit into
Huerte:mainfrom
codekongdev:feat/158-count-triplets

Conversation

@codekongdev

Copy link
Copy Markdown
Contributor

Summary

Add a Python solution for HackerRank's Count Triplets as solutions/python/practice409.py. It counts earlier single values and pairs waiting for each next value, preserving index order in expected O(n) time and O(n) space. Completing triplets before registering the current value handles a ratio of 1 without reusing an index.

Includes 16 executable assertions covering the three official samples, duplicate values, short inputs, index order, large values, and a 100,000-element input.

Related issue

Closes #158

Validation

  • python3 solutions/python/practice409.py — all 16 assertions passed.
  • Compared against an independent brute-force oracle for 16,380 exhaustive cases and 1,000 seeded random cases; input lists remain unchanged.
  • Required solution-header validation passed for the added file.
  • Syntax and whitespace checks passed.
  • HackerRank platform submission and hidden tests have not been run; these results are from local validation.

Checklist

  • The solution includes the required problem, source, and note header comment.
  • The file is in the correct solutions/<language>/ folder 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 f92099e into Huerte:main Nov 4, 2026
1 check passed
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.

Add one Codewars or HackerRank solution you have already solved

2 participants