FastPrepFocus on Efficiency (2024 NG)
Problems/Focus on Efficiency (2024 NG)

Focus on Efficiency (2024 NG)

Google logoGoogle● EasyFULLTIMEOA

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

Given an array of integers A, with each move you can select an arbitrary range and increment all the numbers in that range by 1. Return the number of moves needed to transform an array starting with all zeros into A.

Function

minMoves(A: int[]) → int

Examples

Example 1

A = [2, 1, 3]return = 4

To transform [0, 0, 0] into [2, 1, 3] requires 4 moves, as follows:

[0, 0, 0] -> [1, 1, 1] -> [2, 1, 1] -> [2, 1, 2] -> [2, 1, 3]

Constraints

  • 1 <= A.length <= 10^5
  • 0 <= A[i] <= 10^4

More Google interview questions

  • Swap Adjacent in LR StringONSITE INTERVIEW · Seen Dec 2026
  • Count Winning Dice Face PairsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Find a Failing Test PairONSITE INTERVIEW · Seen Nov 2026
  • Logger Rate LimiterPHONE SCREEN · Seen Nov 2026
  • Logger Rate Limiter with Every-Arrival HistoryPHONE SCREEN · Seen Nov 2026
  • Minimum Cars for Rental RequestsOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Minimum Operations to Make a SubsequenceOA · Seen Nov 2026
  • Periodic-Color Binary Forest RootsPHONE SCREEN · Seen Nov 2026
  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Minimum AmountBelvedere Trading · OA
  • Minimum Cost K-Capable ModelsMicrosoft · OAMicrosoft interview questions
  • Optimal TransferSnowflake · OASnowflake interview questions
  • Minimize Warehouse Transfer CostAmazon · OA
  • Gas Station Loop StartNutanix · OANutanix interview questions
  • Running Through Walls with Limited EnergyScale AI · OAScale AI interview questions
  • Redistribute MegaseedsRubrik · OARubrik interview questions
  • Make the Array PositiveAtlassian · OAAtlassian interview questions
  • Maximum Distinct Items Within a BudgetAdobe · OAAdobe interview questions
  • Maximize Compatible Car RidersUber Freight · PHONE SCREEN · ONSITE INTERVIEWUber Freight interview questions

Interview reports that mention this question

  • Google OA: What It Tests (2026)

Google interview experiences

  • Google interviews · November 2026
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
  • Google Experienced SWE First Round and Onsite: 1 Experience
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public int minMoves(int[] A) {
      // write your code here
    }

}
Checking account…