PracHub
QuestionsCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates array manipulation and algorithmic problem-solving skills, focusing on reasoning about cumulative (suffix) sums and time-complexity analysis. Commonly asked in the Coding & Algorithms domain because it probes efficiency and optimization over naive approaches, it targets practical, implementation-level understanding rather than purely conceptual theory.

  • medium
  • LinkedIn
  • Coding & Algorithms
  • Data Scientist

Find index with positive suffix sums

Company: LinkedIn

Role: Data Scientist

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

Given an unsorted integer array \(A\), find an index \(i\) such that every cumulative sum starting from \(i\) to the end of the array is strictly positive: - \(A[i] > 0\) - \(A[i] + A[i+1] > 0\) - \(A[i] + A[i+1] + A[i+2] > 0\) - ... - \(\sum_{k=i}^{n-1} A[k] > 0\) Return any valid index. If no such index exists, return \(-1\). First describe a baseline solution, then optimize it. Aim for better than \(O(n^2)\) time.

Quick Answer: This question evaluates array manipulation and algorithmic problem-solving skills, focusing on reasoning about cumulative (suffix) sums and time-complexity analysis. Commonly asked in the Coding & Algorithms domain because it probes efficiency and optimization over naive approaches, it targets practical, implementation-level understanding rather than purely conceptual theory.

Return the leftmost index i such that every cumulative sum from i through any later endpoint is strictly positive, or -1.

Constraints

  • Inputs are Python literals matching the function signature.
  • Return a deterministic exact-match value.

Examples

Input: ([-1,2],)

Expected Output: 1

Explanation: Index 1 has positive cumulative sums.

Input: ([2,-3,5],)

Expected Output: 2

Explanation: Only the last index works.

Input: ([-1,-2],)

Expected Output: -1

Explanation: No valid index exists.

Input: ([1,2,-1],)

Expected Output: 0

Explanation: Index 0 works for every suffix cumulative sum.

Hints

  1. Clarify edge cases before coding.
  2. Keep the return value deterministic.
Last updated: Jun 27, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Count Trips From Vehicle Logs - LinkedIn (easy)
  • Design O(1) Randomized Multiset - LinkedIn (easy)
  • Process Mutable Matrix Sum Queries - LinkedIn (medium)
  • Design a Randomized Multiset - LinkedIn (medium)
  • Can You Place N Objects? - LinkedIn (medium)