IBM India Online Assessment (OA) | Application developer-Cloud fullstack

ibm logo
ibm
· Application developer-Cloud fullstack
August 29, 2026 · 1 reads

Summary

I completed a 60‑minute HackerRank online assessment for an Application Developer – Cloud Full‑Stack role at IBM India, which consisted of two coding problems.

Full Experience

Overview

Assessment MetricDetails
CompanyIBM India
RoleApplication developer-Cloud fullstack
Duration60 Minutes
PlatformHackerRank
Total Problems2

Problem 1: Maximize Rental Revenue

Problem Statement

In a cloud computing platform, there are $n$ virtual machine (VM) types. The number of available instances for each type is given in an array vmStock of size $n$.

Each customer rents exactly one VM. The price paid is the current available instance count of the chosen VM type at that moment. Customers arrive sequentially ($m$ customers total).

Each customer always selects the VM type that is currently most expensive, meaning the type with the highest remaining stock. If multiple VM types tie for highest stock, any of them may be chosen. After a VM is rented, that chosen VM type's stock decreases by $1$.

Compute the total maximum revenue earned after serving all $m$ customers.

Constraints

  • $1 \le n \le 10^5$
  • $1 \le \text{vmStock}[i] \le 10^6$
  • $1 \le m \le 10^6$
  • $\sum_{i=0}^{n-1} \text{vmStock}[i] > m$

Input Format

  • The first line contains an integer $n$, denoting the number of elements in vmStock.
  • Each line $i$ of the $n$ subsequent lines contains an integer, vmStock[i].
  • The last line contains an integer $m$, denoting the total number of customers.

Sample Cases

Sample 0

Input:

4
2
1
1
3
4

Output:

8

Explanation:

  • Initial stock: [2, 1, 1, 3]
  • Customer 1 picks stock 3 (Cost = 3), remaining stock: [2, 1, 1, 2]
  • Customer 2 picks stock 2 (Cost = 2), remaining stock: [1, 1, 1, 2]
  • Customer 3 picks stock 2 (Cost = 2), remaining stock: [1, 1, 1, 1]
  • Customer 4 picks stock 1 (Cost = 1), remaining stock: [0, 1, 1, 1]
  • Total revenue: $3 + 2 + 2 + 1 = 8$.

Sample 1

Input:

3
10
10
11
3

Output:

31

Explanation:

  • Customer 1 picks stock 11 (Cost = 11), remaining stock: [10, 10, 10]
  • Customer 2 picks stock 10 (Cost = 10), remaining stock: [9, 10, 10]
  • Customer 3 picks stock 10 (Cost = 10), remaining stock: [9, 9, 10]
  • Total revenue: $11 + 10 + 10 = 31$.

Template Code

import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.function.*;
import java.util.regex.*;
import java.util.stream.*;
import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toList;

class Result {

    /*
     * Complete the 'maximizeRentalRevenue' function below.
     *
     * The function is expected to return a LONG.
     * The function accepts following parameters:
     *  1. INTEGER_ARRAY vmStock
     *  2. INTEGER m
     */

    public static long maximizeRentalRevenue(List<Integer> vmStock, int m) {
        // Write your code here

    }

}

public class Solution {
    public static void main(String[] args) throws IOException {
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH")));

        int vmStockCount = Integer.parseInt(bufferedReader.readLine().trim());

        List<Integer> vmStock = IntStream.range(0, vmStockCount).mapToObj(i -> {
            try {
                return bufferedReader.readLine().replaceAll("\\s+$", "");
            } catch (IOException ex) {
                throw new RuntimeException(ex);
            }
        })
            .map(String::trim)
            .map(Integer::parseInt)
            .collect(toList());

        int m = Integer.parseInt(bufferedReader.readLine().trim());

        long result = Result.maximizeRentalRevenue(vmStock, m);

        bufferedWriter.write(String.valueOf(result));
        bufferedWriter.newLine();

        bufferedReader.close();
        bufferedWriter.close();
    }
}

Problem 2: plusMult (pluwult)

Problem Statement

Given an array $A$ of integers, determine whether the array is ODD, EVEN, or NEUTRAL using the following calculations (the symbol % denotes the modulo operator):

  1. Compute $R_{\text{even}}$ using elements at even indices ($0, 2, 4, 6, 8, \dots$):

    • Starting with $A[0]$, alternate between multiplying and adding subsequent even-indexed elements, and evaluate the final result modulo 2: $$R_{\text{even}} = (\dots(((A[0] \times A[2]) + A[4]) \times A[6]) + A[8] \dots) \pmod 2$$
  2. Compute $R_{\text{odd}}$ using elements at odd indices ($1, 3, 5, 7, 9, \dots$):

    • Starting with $A[1]$, alternate between multiplying and adding subsequent odd-indexed elements, and evaluate the final result modulo 2: $$R_{\text{odd}} = (\dots(((A[1] \times A[3]) + A[5]) \times A[7]) + A[9] \dots) \pmod 2$$
  3. Classification:

    • If $R_{\text{odd}} > R_{\text{even}}$, return "ODD".
    • If $R_{\text{even}} > R_{\text{odd}}$, return "EVEN".
    • If $R_{\text{even}} = R_{\text{odd}}$, return "NEUTRAL".

Constraints

  • $1 \le n \le 10^5$ (or $10 \le n \le 10^5$)
  • $-10^9 \le A[i] \le 10^9$

Input Format

  • The first line contains an integer $n$, denoting the size of array $A$.
  • Each line $i$ of the $n$ subsequent lines contains an integer, $A[i]$.

Sample Cases

Sample 0

Input:

6
12
3
6
7
13
12

Output:

NEUTRAL

Explanation:

  • $A = [12, 3, 6, 7, 13, 12]$
  • Even-indexed elements: $A[0] = 12, A[2] = 6, A[4] = 13$ $$R_{\text{even}} = ((12 \times 6) + 13) \pmod 2 = (72 + 13) \pmod 2 = 85 \pmod 2 = 1$$
  • Odd-indexed elements: $A[1] = 3, A[3] = 7, A[5] = 12$ $$R_{\text{odd}} = ((3 \times 7) + 12) \pmod 2 = (21 + 12) \pmod 2 = 33 \pmod 2 = 1$$
  • Since $R_{\text{even}} = 1$ and $R_{\text{odd}} = 1$, $R_{\text{even}} = R_{\text{odd}} \implies$ "NEUTRAL".

Template Code

import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.function.*;
import java.util.regex.*;
import java.util.stream.*;
import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toList;

class Result {

    /*
     * Complete the 'pluwult' function below.
     *
     * The function is expected to return a STRING.
     * The function accepts INTEGER_ARRAY A as parameter.
     */

    public static String pluwult(List<Integer> A) {
        // Write your code here

    }

}

public class Solution {
    public static void main(String[] args) throws IOException {
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH")));

        int aCount = Integer.parseInt(bufferedReader.readLine().trim());

        List<Integer> A = IntStream.range(0, aCount).mapToObj(i -> {
            try {
                return bufferedReader.readLine().replaceAll("\\s+$", "");
            } catch (IOException ex) {
                throw new RuntimeException(ex);
            }
        })
            .map(String::trim)
            .map(Integer::parseInt)
            .collect(toList());

        String result = Result.pluwult(A);

        bufferedWriter.write(result);
        bufferedWriter.newLine();

        bufferedReader.close();
        bufferedWriter.close();
    }
}

Interview Questions (2)

1.

Maximize Rental Revenue

Data Structures & Algorithms

In a cloud computing platform, there are $n$ virtual machine (VM) types. The number of available instances for each type is given in an array vmStock of size $n$.

Each customer rents exactly one VM. The price paid is the current available instance count of the chosen VM type at that moment. Customers arrive sequentially ($m$ customers total).

Each customer always selects the VM type that is currently most expensive, meaning the type with the highest remaining stock. If multiple VM types tie for highest stock, any of them may be chosen. After a VM is rented, that chosen VM type's stock decreases by $1$.

Compute the total maximum revenue earned after serving all $m$ customers.

Constraints

  • $1 \le n \le 10^5$
  • $1 \le \text{vmStock}[i] \le 10^6$
  • $1 \le m \le 10^6$
  • $\sum_{i=0}^{n-1} \text{vmStock}[i] > m$

Input Format

  • The first line contains an integer $n$, denoting the number of elements in vmStock.
  • Each line $i$ of the $n$ subsequent lines contains an integer, vmStock[i].
  • The last line contains an integer $m$, denoting the total number of customers.

Sample Cases

  • Sample 0 Input: 4 2 1 1 3 4 Output: 8
  • Sample 1 Input: 3 10 10 11 3 Output: 31
2.

plusMult (pluwult)

Data Structures & Algorithms

Given an array $A$ of integers, determine whether the array is ODD, EVEN, or NEUTRAL using the following calculations (the symbol % denotes the modulo operator):

  1. Compute $R_{\text{even}}$ using elements at even indices (0,2,4,…): start with $A[0]$, alternate multiplication and addition across even‑indexed elements, then take the result modulo 2.
  2. Compute $R_{\text{odd}}$ using elements at odd indices (1,3,5,…): start with $A[1]$, alternate multiplication and addition across odd‑indexed elements, then take the result modulo 2.
  3. If $R_{\text{odd}} > R_{\text{even}}$ return ODD; if $R_{\text{even}} > R_{\text{odd}}$ return EVEN; otherwise return NEUTRAL.

Constraints

  • $1 \le n \le 10^5$
  • $-10^9 \le A[i] \le 10^9$

Input Format

  • First line: integer $n$ (size of array).
  • Next $n$ lines: integer $A[i]$.

Sample Input: 6 12 3 6 7 13 12 Output: NEUTRAL

📣 Found this helpful? Please share it with friends who are preparing for interviews!

Discussion (0)

Share your thoughts and ask questions

Join the Discussion

Sign in with Google to share your thoughts and ask questions

No comments yet

Be the first to share your thoughts and start the discussion!