Skip to main content
All Questions

Find the maximum subarray score where the score is first plus last minus the middle sum.

Unlock detailed company stats for this questionUpgrade

Given an array such as [3, 1, 2, 4, 5], calculate the maximum subarray score, where a subarray's score is its first element plus its last element minus the sum of its middle elements. Example: [3, 1, 2, 4] scores 4 + 3 - (1 + 2) = 4; the best valid subarray is [4, 5] with answer 9.

Format · Onsite DSA round, single question.

Community answers

No answers contributed by the community yet.

Related courses

Course

AI Engineering Interview Prep

Ace the AI engineering interview at top companies like Google, Anthropic, Meta, and OpenAI. Learn from detailed frameworks, example questions, and mock interviews with senior engineers. Practice system design, AI/ML concepts, AI-assisted coding, and behavioral rounds.

Course

Generative AI Interviews

Ace your interviews at AI-first and AI-powered companies. Learn to explain how Gen AI really works, where it fails, and how to use it responsibly. Understand how top tech companies build and deploy AI products and how generative AI works in production, from LLMs and RAG systems to real-world deployment.