Jupiter | SDE 2 | 28 January 2025 | Waiting For Results

1750
Feb 02, 2025

Jupiter | SDE 2 | 28 January 2025


Interview Process and Format

Round 1: Technical Interview (1 Hour)

Behavioral Questions:

  • Introduction: The interviewer asked about my professional background and past projects.
  • Expectations: Discussed my interest in the role and career aspirations.

Technical Questions:

1. Minimum Days to Form Bouquets

I was given an array where arr[i] represents the day the i-th rose blooms. The goal was to find the minimum number of days required to form at least m bouquets, each containing exactly k adjacent bloomed roses.

Example Input:
N = 8, arr = {7, 7, 7, 7, 13, 11, 12, 7}, m = 2, k = 3
Expected Output: 12
Approach:
  • Used Binary Search to find the minimum valid day.
  • Created a helper function checkBoquetFormation() to check if bouquets can be formed on a given day.
  • If m * k > N, immediately returned -1 as it's impossible.
Code Snippet:
public static boolean checkBoquetFormation(int[] arr, int m, int k, int day) {
    int count = 0, bouquet = 0;
    for (int bloomDay : arr) {
        if (bloomDay <= day) {
            count++;
            if (count == k) {
                bouquet++;
                count = 0;
            }
        } else {
            count = 0;
        }
    }
    return bouquet >= m;
}

public static int findMinDays(int[] arr, int m, int k) {
    if (m * k > arr.length) return -1;

    int left = 1, right = Integer.MAX_VALUE, result = -1;
    while (left <= right) {
        int mid = left + (right - left) / 2;
        if (checkBoquetFormation(arr, m, k, mid)) {
            result = mid;
            right = mid - 1;
        } else {
            left = mid + 1;
        }
    }
    return result;
}
Complexity Analysis:
  • Binary Search: O(log max(arr) * N)
  • Overall Complexity: O(N log max(arr))

2. Treasure Hunt in a Sorted Matrix

The problem was to search for a given target in a sorted 2D matrix where:

  • Each row is sorted left to right.
  • Each column is sorted top to bottom.
Example Input:
matrix = [
  [1,  4,  7,  11, 15],
  [2,  5,  8,  12, 19],
  [3,  6,  9,  16, 22],
  [10, 13, 14, 17, 24],
  [18, 21, 23, 26, 30]
]
target = 5
Expected Output: true
Approach:
  • Used Binary Search from the top-right corner.
  • If matrix[row][col] == target, return true.
  • If matrix[row][col] > target, move left.
  • If matrix[row][col] < target, move down.
Code Snippet:
public static boolean searchMatrix(int[][] matrix, int target) {
    int rows = matrix.length, cols = matrix[0].length;
    int r = 0, c = cols - 1;

    while (r < rows && c >= 0) {
        if (matrix[r][c] == target) return true;
        else if (matrix[r][c] > target) c--; // Move left
        else r++; // Move down
    }
    return false;
}
Complexity Analysis:
  • Time Complexity: O(m + n) (Worst-case: traverse one row and one column)
  • Space Complexity: O(1)

Performance & Feedback:

  • ✅ Solved both problems within the 1-hour timeframe.
  • ⚠ Needed to improve how I explained my approach concisely.
  • 📌 Waiting for results—will update if I get further feedback.

My Thoughts:

The problems were well-structured and tested binary search, matrix traversal, and logical thinking. I performed well in solving them but need to refine how I explain my thought process under pressure.

Comments (5)