HackerRank Problem Solving Certification Prep: Match Basic and Intermediate Skills to Practice
Quick Overview
Compare the published Basic and Intermediate competencies, then test two original exercises using a pair-counting oracle, a three-state DP trace, and boundary cases.
HackerRank Problem Solving certification preparation starts with a more useful question than “Which answers should I memorize?” Ask which operations you can implement, test, and explain without a familiar problem title. Basic and Intermediate share an algorithmic foundation, but the published competency descriptions call for different evidence of readiness.
This guide maps those descriptions to two original exercises: counting nearby measurement pairs and choosing shifts without selecting three consecutive positions. You will build a baseline, justify an improvement, and use small counterexamples to expose mistakes. Start with Explain a Sorting Algorithm Such as Merge Sort: Mechanics, Correctness, Complexity if you can call a sorting function but cannot explain its cost.
Evidence boundary: Official HackerRank pages support the skill and format statements below. Our current research did not establish two independent, same-cycle candidate reports for these exact certifications, so this article makes no candidate-reported claims about private questions, passing scores, or grading. The exercises and readiness advice are PracHub editorial practice, not HackerRank exam material.

What separates Problem Solving Basic from Intermediate?
Official scope: The Basic skill directory includes arrays and strings, traversal of trees and linked lists, element access and updates, and simple sorting, searching, and brute-force approaches. The Intermediate directory adds maps, stacks, queues, heaps, linked-list and tree information, complexity analysis, optimal solutions, and simple dynamic programming.
That difference is not a promise that a particular data structure will appear. Prepare the listed competencies, then let each task's constraints determine the method. A tiny input may justify exhaustive search; a large one can make the same correct approach impractical.
| Published area | Evidence you can produce | What these exercises leave open |
|---|---|---|
| Basic arrays, sorting, and search | Enumerate pairs, sort a copy, explain a moving boundary | Implementing a sort and binary search yourself |
| Basic traversal | Read every relevant position without skipping cases | Tree and linked-list traversal |
| Intermediate complexity and optimal solutions | Compare enumeration with a linear scan after sorting | Other optimization patterns and lower bounds |
| Intermediate simple dynamic programming | Define three states and derive transitions | Larger state spaces and reconstruction |
| Intermediate structures | Choose a structure from required operations | Hash maps, stacks, queues, heaps, and tree metadata need separate practice |
Treat two solved exercises as a diagnostic sample, then use the last column to choose your next drill. In particular, sorting an array does not demonstrate pointer manipulation, and recognizing a recurrence does not demonstrate heap operations.
What format is currently published?
Official format checked October 11, 2026: Both the Basic catalog and Intermediate catalog currently show two questions and a 90-minute assessment. Recheck your selected catalog and on-screen instructions before starting; a current listing is not a permanent rule.
HackerRank's certification FAQ says it does not provide certification questions or solutions. Use the platform's current instructions for permitted languages, environment behavior, and submission rules. An employer's HackerRank invitation is a separate assessment context; this article's catalog facts do not establish its format.
Editorial recommendation: Rehearse translating a complete contract into a working function before attempting timed practice. Record whether lost time came from an unclear output contract, a broken loop invariant, or a failing boundary case. An unfinished submission can still identify the next useful practice step: clarify the contract, trace the loop, or isolate the failing input.
Basic-focused task: count nearby measurement pairs
This original task accepts an integer list values and a nonnegative integer gap. Count unordered pairs of distinct positions whose absolute value difference is at most gap. Equal values at different positions count separately. Return an integer, preserve the input list, and raise ValueError for a negative gap. Empty and singleton lists return zero.
For [7, 1, 4, 4] with gap 3, the answer is 5: 1 pairs with each 4, the two 4 positions pair together, and each 4 pairs with 7. Only 1 with 7 fails. Count positions explicitly before trusting a plausible total.
The quadratic baseline checks every i < j and increments the answer when abs(values[i] - values[j]) <= gap. It uses constant extra space and considers each pair exactly once. Keep it as a small-input oracle rather than discarding it after finding an improvement.
Sorting reveals a useful property. For each right position, valid left partners form a suffix of the earlier sorted positions. Advance left until the difference is within the gap; then all positions from left through right - 1 qualify.
def count_nearby_pairs(values, gap):
if gap < 0:
raise ValueError("gap must be nonnegative")
ordered = sorted(values)
left = 0
count = 0
for right, value in enumerate(ordered):
while value - ordered[left] > gap:
left += 1
count += right - left
return count
The loop can safely access ordered[left]: a nonnegative gap means the current element's difference from itself is zero, so left never needs to move past right. Empty input never enters the loop. The function uses sorted to avoid changing the caller's list; replacing it with an in-place sort would violate this contract.
At each right boundary, every discarded earlier value is too small, and every retained earlier value qualifies. The sorted order makes these statements monotone. Adding right - left counts exactly the pairs whose later sorted position is right; no pair is counted twice.
Sorting costs O(n log n) time, and both pointers advance at most n times in the scan. This Python implementation uses O(n) extra space for the sorted copy and sorting workspace. If asked to implement merge sort, show that implementation separately; a library call does not prove the published sorting competency by itself.
Use inputs that distinguish wrong pair-counting solutions
| Input and gap | Expected count | Mistake it exposes |
|---|---|---|
[], 3 | 0 | Assuming at least one value |
[4], 0 | 0 | Counting a value paired with itself |
[4, 4, 4], 0 | 3 | Deduplicating values instead of positions |
[1, 4], 3 | 1 | Using a strict inequality at the boundary |
[-5, -2, 1], 3 | 2 | Treating negative values as invalid |
[7, 1, 4, 4], 3 | 5 | Missing cross-pairs after sorting |
A gap of zero permits equal values; it does not mean “return zero.” For an all-equal list of length n, the expected count is n(n-1)/2. In fixed-width integer languages, check whether the maximum pair count fits the accumulator type, even if every input value fits.
For automated checking, enumerate short lists from a small signed value domain and compare the optimized count with the nested-loop result for several gaps. Compare the DP result with every legal subset on similarly small arrays. Save a failing input before changing the code; a reproducible counterexample is more useful than another random successful run. Comparing against independently structured oracles can expose mistakes that a few hand-written examples miss. They do not prove performance at the largest allowed input. Complexity analysis still explains why the scan scales, while the correctness argument explains why all legal choices are represented.
Now change one requirement: return original index pairs instead of only a count. Sorting bare values loses the index identities. You would need to retain indexes, and enumerating all matching pairs can itself require quadratic output. State that change rather than promising the counting algorithm's runtime for a larger output contract.
Intermediate-focused task: choose shifts without three consecutive selections
The second original task gives an integer list points. Choose any subset of positions, including the empty subset, to maximize its sum. You may select two consecutive positions, but never three consecutive positions in the original list. Negative values are allowed. Return only the best sum and preserve input order.
For [4, 5, 6], the answer is 11, selecting the last two positions. An algorithm that forbids all adjacent selections returns 10 and solves a different problem. For [8, -100, 9, 10], skipping the negative position allows the other three selections, totaling 27; they do not form three consecutive original positions.
An exhaustive baseline enumerates all 2^n subsets, rejects masks containing three consecutive selected positions, and computes each remaining sum. A straightforward implementation takes O(n·2^n) time. This is useful on tiny arrays for verification, not on large inputs.
Define state by the number of consecutive selected positions at the end of the processed prefix. zero means the latest position was skipped; one means a selected suffix of length one; two means a selected suffix of length two. Each stores the best attainable sum for that exact ending condition.
def best_shift_points(points):
zero = 0
one = two = float("-inf")
for value in points:
zero, one, two = (
max(zero, one, two),
zero + value,
one + value,
)
return max(zero, one, two)
Skipping the new position can follow any old state. Selecting it after a skipped position creates a suffix of length one; selecting it after a suffix of length one creates length two. There is no transition that selects after length two. Impossible states start at negative infinity, while skipping everything remains feasible with value zero.
Python evaluates the right-hand side before assigning the three names. Three sequential assignments using already-updated values can reuse the same position and invent an impossible score. If your language lacks parallel assignment, compute three temporary next-state variables before replacing the old states.

Trace the states and test the recurrence
| Processed prefix | zero | one | two |
|---|---|---|---|
| Empty | 0 | impossible | impossible |
[4] | 0 | 4 | impossible |
[4, 5] | 4 | 5 | 9 |
[4, 5, 6] | 9 | 10 | 11 |
Every valid selection ends in exactly one of these three states. The transitions cover all legal ways to skip or select the next position, and taking the maximum retains the best sum for each ending condition. Induction over processed positions therefore establishes correctness; the final maximum considers every valid ending.
This algorithm takes O(n) time and O(1) auxiliary state for the best sum. It does not return the selected indexes. Reconstructing a particular selection requires retaining predecessor information or another deliberate strategy, including a tie rule. Do not quietly claim that the three running values already provide that output.
Check [] → 0, [-3, -2] → 0, [5] → 5, [5, 5] → 10, and [5, 5, 5, 5] → 15. The all-negative case exposes an initialization that wrongly forces a selection. The two-element case catches accidental reuse of the usual no-adjacent recurrence.
Five PracHub questions to cover the remaining gaps
These linked PracHub records are candidate-reported practice prompts, not reports of questions appearing in either certification. Some destinations may require an account or Premium access. Choose the prompt that addresses a demonstrated gap rather than treating the list as an exam prediction.
| PracHub question | Practice purpose |
|---|---|
| Explain a Sorting Algorithm Such as Merge Sort: Mechanics, Correctness, Complexity | Implement the sorting work hidden by a library call |
| Solve common data-structure and puzzle problems | Rehearse linked-list traversal and pointer changes |
| Implement a FIFO Queue Using Two Stacks | Explain operation order and amortized complexity |
| Implement longest subarray summing to k | Use a map when negative values defeat an ordinary sum window |
| Maximize sum with no adjacent elements | Compare a different adjacency contract and recurrence |
Decide which evidence you still need
Use these exercises to find gaps. If you can only reproduce the optimized code, return to the oracle and proof. If the algorithms work but you cannot state their memory cost, rehearse the copied array and the three DP states explicitly. If both tasks feel comfortable, practice the uncovered structures rather than assuming completion.
For a timed rehearsal, choose an unfamiliar task, write the contract, produce runnable code, and reserve time to submit and check observable results. That is editorial preparation advice, not an official timing allocation or scoring rubric. Use the checks to choose what to study next; they are not a prediction of certification or hiring outcomes.
Continue with Implement a FIFO Queue Using Two Stacks to test a different Intermediate structure. For the separate question of résumé placement, read Are HackerRank Certifications Worth Adding to a Software Engineer Resume?.
Comments (0)