CONTENTS

    Questions I Encountered in the IBM HackerRank Test Experience

    avatar
    Silvia AN
    ·September 20, 2025
    ·9 min read
    What Kind of Questions Did I Encounter in My IBM HackerRank Test

    As someone who has just passed the IBM HackerRank test, I know well that many job seekers are looking everywhere for reliable preparation materials, yet they always fail to find content that truly aligns with real exam scenarios, and I was no exception. So in this article, I will directly share the interview questions I encountered, and also pass on other real interview questions I have collected, so that you can avoid unnecessary detours.

    I also tested a very useful AI tool for you. It’s a product by Linkjob that can be used during interviews. The AI can directly capture screenshots in the OA, analyze the questions, and generate answers. Since the results are only visible to you, the interviewer won’t notice, and it won’t be detected by the system.

    IBM HackerRank Test Questions

    The following two are complete real questions I encountered in the IBM HackerRank Test, including my problem-solving process and key points to note.

    Question 1: Find Indices of High-Load Timestamps

    Problem Requirement

    Given an integer array load (of length n) representing server loads at different timestamps, find all 0-based indices where the load value is greater than twice the average load. Return the results in increasing order; if no such indices exist, return an empty array.

    Example

    • Input: n=3, load=[1,2,9]

    • Calculation: Average load = (1+2+9)/3 = 4; twice the average load = 8. Only the load at index 2 (value 9) is greater than 8.

    • Output: [2]

    My Solution Approach

    1. Handle edge cases first: If n=0, return an empty array directly. (However, per the constraint 1≤n≤2×10⁵, we don’t actually need to handle n=0 in practice, but adding this check makes the code more robust.)

    2. Calculate the total sum of the array: Since load[i] can be as large as 10⁹ and n up to 2×10⁵, the total sum may exceed the int limit. Use a long type to store the sum.

    3. Compute the average load: Avoid debating “integer vs. floating-point division.” The condition load[i] > 2×average is equivalent to load[i]×n > 2×total sum. Using integer calculation eliminates floating-point precision errors and improves efficiency.

    4. Traverse the array: Check each load[i] to see if it satisfies load[i]×n > 2×total sum. If yes, add its index to the result list.

    5. Return the result list (it is naturally in increasing order since we traverse the array sequentially).

    Key Code Reminders

    • Avoid calculating “average first, then multiply by 2” to prevent floating-point errors (e.g., if the total sum isn’t divisible by n, the average becomes a decimal, leading to incorrect judgments).

    • Use long for the total sum to avoid int overflow (e.g., 10⁹×2×10⁵=2×10¹⁴, which far exceeds the maximum int value).

    Question 2: Calculate Minimum Total Cost to Select All Items

    Problem Requirement

    There are numItems items (numbered from 0 to numItems-1), and each item may have multiple cost options. Given two arrays itemId (length n, each element is an item number) and cost (length n, the corresponding cost for each item number), select exactly one cost option for each item and find the minimum total cost. If any item has no cost options, return -1.

    Example

    • Input: numItems=3, n=4, itemId=[2,0,1,2], cost=[8,7,6,9]

    • Analysis: The minimum cost for item 0 is 7, for item 1 is 6, and for item 2 is 8 (choosing the smaller value between 8 and 9).

    • Output: 7+6+8=21

    My Solution Approach

    1. Initialize a “minimum cost array”: With length numItems and initial values set to a large number (e.g., Long.MAX_VALUE), this array stores the minimum cost for each item.

    2. Traverse the itemId and cost arrays: For each index i, get the current item number id = itemId[i] and corresponding cost c = cost[i]. If c < minimum cost array[id], update minimum cost array[id] = c.

    3. Check for items with no cost options: Traverse the “minimum cost array.” If any element remains the initial large value, the corresponding item has no cost options—return -1.

    4. Calculate the total cost: If all items have minimum costs, sum all values in the array and return the total (use long to avoid int overflow).

    Key Code Reminders

    • Item numbers range from 0 to numItems-1, so the “minimum cost array” can be directly set to length numItems without handling disorganized numbering.

    • When using Long.MAX_VALUE as the initial large value, avoid overflow during summation. (However, since cost contains positive integers, the total sum will not exceed 10⁹×2×10⁵=2×10¹⁴ if all items have costs—easily accommodated by long.)

    I used Linkjob to help me answer both of these questions. After downloading, you just need to keep it running during the interview and use it when needed. Its stealth features are truly one of a kind, it can even hide the app icon. For example, on my Mac interview computer, its icon can be hidden from the dock.

    Best Stealthy AI Interview Copilot

    IBM HackerRank Test Experience

    As a supplement, I also compiled some real questions mentioned in interview experiences.

    Experience 1 - IBM Internship HackerRank OA for 26 NG

    Question 1: Frequent IP Addresses in a Time Window

    Problem Statement

    Given arrays of IP addresses and their respective timestamps, find all IP addresses that appear more than k times within any t-second window. If no such IP addresses exist, return an empty array.

    Input

    • ip: an array of integers representing IP addresses.

    • timestamp: an array of integers representing the timestamps for each IP.

    • k: an integer threshold for the number of occurrences.

    • t: an integer representing the time window in seconds.

    Output

    • An array of integers representing the IP addresses that appear more than k times within any t-second window. Return an empty array if none exist.

    Example

    n = 3
    ip = [1, 2, 1]
    timestamp = [6, 10, 15]
    k = 1
    t = 10
    
    # Output
    [1]

    Notes

    • Timestamps are in seconds and sorted in ascending order.

    • Multiple IPs can satisfy the condition; return all of them.

    Question 2: Earliest Time to Reach Target on a Grid

    Problem Statement

    In a 2D grid, you start at coordinate (startX, startY) and want to reach (endX, endY). You are given a string directions of length n, containing characters representing moves:

    • E: move right (x+1, y)

    • S: move down (x, y-1)

    • W: move left (x-1, y)

    • N: move up (x, y+1)

    At the ith second, you can either move one unit in the direction specified by directions[i] or stay in place. Implement a function to calculate the earliest time required to reach the target. Return -1 if the target cannot be reached within n seconds.

    Input

    • startX, startY: integers representing the starting coordinates.

    • endX, endY: integers representing the target coordinates.

    • directions: string of length n representing the moves at each second.

    Output

    • An integer representing the earliest time at which the target can be reached, or -1 if unreachable within n seconds.

    Example:

    directions = "WWNNSSE"
    startX = 1
    startY = -1
    endX = -1
    endY = -1
    
    # Output
    6

    Notes

    • You can choose to stay in place instead of following the direction at a particular second.

    • Return the earliest time possible.

    Experience 2 - IBM SDE HackerRank OA

    Question 1: Max Uniform Team Size

    Question 2: Prefix Count with Length Constraint

    Experience 3 - IBM AI Engineer Intern HackerRank OA

    Question 1: Login Replacement Counter

    Problem Statement

    You are given a list of login attempts for multiple users. Each login attempt contains a login_id and a login_status.

    Whenever the same login_id encounters three consecutive "error" statuses, the account must be replaced and the error count reset.

    Your task is to calculate the total number of replacements across all users.

    Input Format

    • An integer n — the number of login attempts.

    • n lines, each containing:

      • login_id (string)

      • login_status (string, "success" or "error")

    Output Format

    An integer — the total number of replacements.

    Constraints

    • 1 ≤ n ≤ 10^5

    • Each login_id is alphanumeric.

    • Status is always "success" or "error".

    Example Input

    7
    u1 error
    u1 error
    u1 error
    u2 error
    u2 success
    u2 error
    u2 error

    Example Output

    1

    Explanation

    • u1 has 3 consecutive errors → 1 replacement.

    • u2 never reaches 3 consecutive errors.

    • Total replacements = 1.

    Question 2: Shortest Path With Optional Moves

    Problem Statement

    You are given:

    • A string directions of length n, consisting of characters "E", "W", "N", "S".

    • A starting coordinate (startX, startY).

    • A target coordinate (endX, endY).

    At the i-th second (0 ≤ i < n), you can:

    1. Move one step in the direction directions[i], OR

    2. Stay at the current position.

    Your task is to return the earliest time (an integer) when you can reach (endX, endY).

    If it is not possible to reach the target within n steps, return -1.

    Input Format

    • String directions of length n.

    • Four integers: startX startY endX endY.

    Output Format

    An integer — the earliest time to reach the target, or -1 if impossible.

    Constraints

    • 1 ≤ n ≤ 10^5

    • Coordinates are integers within range [−10^9, 10^9].

    Example Input

    WWNNSSE
    1 -1 -1 -1

    Example Output

    6

    Explanation

    • Start at (1, -1) and follow moves.

    • By second 6, it is possible to reach (−1, −1).

    • Answer = 6.

    I have one more thing to add about Linkjob.ai. Apart from solving technical problems, it can also discreetly answer interviewers’ questions during conversations. In the later stages after the OA, I mainly relied on Linkjob. I was very satisfied with the speed of its answer generation, and the responses were personalized based on my own background.

    Best AI Interview Assistant for Job Seekers

    IBM HackerRank Test Interview Summary

    Key Assessment Dimensions

    This test doesn’t just check if you can write code, but focuses on three core dimensions.

    First, the mastery of basic algorithms and data structures, such as array traversal optimization and efficient application of hash tables, ensuring the time complexity of the code meets the constraints.

    Second, code standardization and robustness, requiring clear variable names, concise comments, and the ability to handle boundary cases.

    Third, problem understanding and transformation ability. Some questions have long descriptions, so you need to quickly extract core requirements and convert text into code logic.

    How IBM's HackerRank Test Differs

    Compared with Internet companies, IBM’s HackerRank test focuses more on "practicality" rather than "difficult or biased problems". For example, the question scenarios are more related to the company’s actual business instead of pure algorithm competition questions. IBM's difficulty gradient is gentle, and there are no out-of-syllabus knowledge points. In addition, IBM will provide detailed wrong question analysis after the test, which is a rare "feedback benefit" among most companies.

    IBM HackerRank Test Preparation Tips & Strategies

    Targeted Practice

    There’s no need to blindly practice a large number of questions. Prioritize three types of questions.

    First, array and string operation questions, which account for more than 60%.

    Second, basic hash table application questions, and you need to be proficient in using tools like Java’s HashMap and Python’s dict.

    Third, simple SQL query questions, and mastering basic grammars like SELECT, WHERE, GROUP BY, and JOIN is sufficient.

    Time Management and Emergency Skills

    With limited test duration, it’s necessary to manage time well. Spend 3-5 minutes reading the question first to clarify the "input and output requirements", "constraints", and "core requirements" to avoid rework due to missing conditions.

    If you have no idea about a question within 15 minutes, skip it immediately and prioritize the questions you are sure about to avoid "sticking to one question and leaving all blank".

    Final Check List

    Spend 2-3 minutes doing three things before submission.

    First, verify boundary cases and manually input 1-2 extreme values to confirm that the code output is correct.

    Second, optimize code efficiency. If an O(n²) solution is found, try to use a hash table or sorting to optimize it to O(n) or O(n log n).

    Third, standardize code format, delete redundant comments, and unify variable naming styles.

    IBM pays attention to code readability, and a standardized format may indirectly improve the impression score.

    FAQ

    How can I practice for the IBM HackerRank test?

    I use platforms like LeetCode, HackerRank, and Linkjob for mock interviews. To simulate real test conditions, I set a timer, try to solve problems, and then review my mistakes to learn from them.

    Do I need to know advanced algorithms for the test?

    Most questions focus on basic to medium-level algorithms. I make sure I understand sorting, searching, and simple graph problems. For specialized roles, I review advanced topics, but basics matter most.