Skip to content

Add Kth Largest Element problem (Heaps) - #54

Merged
RuslanLomaka merged 2 commits into
masterfrom
problem/kth-largest-element
Nov 6, 2026
Merged

RuslanLomaka merged 2 commits into
masterfrom
problem/kth-largest-element

Conversation

@RuslanLomaka

Copy link
Copy Markdown
Owner

Summary

  • Adds the "Kth Largest Element" problem to the Heaps topic (previously empty), following the classic "Kth Largest Element in an Array" formulation: findKthLargest(int[] numbers, int k) returns the kth largest value (k = 1 is the largest), with duplicates counted individually.
  • Registers KthLargestElementProblem in ProblemRegistry alongside the existing problems.
  • Adds reference solutions at src/test/resources/solutions/kth-largest-element.txt (min-heap of size k) and kth-largest-element.wrong.txt (returns the kth smallest via sorting, which fails multiple hidden tests on purpose).
  • Bumps ProblemRegistryTest's hasSize(...) assertion from 8 to 9 registered problems.

Only these files were touched: the new problem class, ProblemRegistry.java, the two solution files, and ProblemRegistryTest.java.

Test plan

Ran the scoped, Docker-free validation command (also runs Checkstyle in Maven's validate phase):

$ ./mvnw test -Dtest=HarnessVerificationTest,ProblemDefinitionContractTest,ProblemRegistryTest
...
[INFO] --- checkstyle:3.6.0:check (checkstyle-validate) @ OnlineJava ---
[INFO] You have 0 Checkstyle violations.
...
[INFO] Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.173 s -- in com.example.onlinejava.problem.ProblemRegistryTest
[INFO] Tests run: 18, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 8.170 s -- in com.example.onlinejava.problem.HarnessVerificationTest
[INFO] Tests run: 18, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.072 s -- in com.example.onlinejava.problem.ProblemDefinitionContractTest
[INFO] Tests run: 43, Failures: 0, Errors: 0, Skipped: 0
[INFO] BUILD SUCCESS

The repo's own CI (.github/workflows/ci-cd.yml) will independently re-run the full suite against a real Postgres container before merge is possible.

Opened automatically by a scheduled cloud agent (every 2 hours), not auto-merged -- please review.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GTNCBT8dJKatDtYhD26XwJ


Generated by Claude Code

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GTNCBT8dJKatDtYhD26XwJ
@coderabbitai

coderabbitai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Tip

🎯 Customize your risk assessments

Guide how CodeRabbit assesses merge risk and security architecture risk. Highlight sensitive changes and explain your security boundaries using Merge Risk Instructions and Security Risk Instructions in your review settings. Security architecture risk assessments require the Advanced plan or above.

✅ Automatic approvals, with your rules

Let CodeRabbit approve pull requests once required threads are resolved, pre-merge checks pass, and your risk limits are met. Enable Automatic approvals in review settings, with overrides for teams or file paths.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@sonarqubecloud

Copy link
Copy Markdown

@coderabbitai

coderabbitai Bot commented Oct 1, 2026

Copy link
Copy Markdown

Autopilot could not be updated. Open Coding to check access and billing.

…-element

# Conflicts:
#	src/main/java/com/example/onlinejava/problem/ProblemRegistry.java
#	src/test/java/com/example/onlinejava/problem/ProblemRegistryTest.java
@sonarqubecloud

sonarqubecloud Bot commented Nov 6, 2026

Copy link
Copy Markdown

@RuslanLomaka
RuslanLomaka merged commit 7d18277 into master Nov 6, 2026
4 checks 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.

2 participants