Skip to content

Practice Find the Maximum Achievable Number

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#2769
LeetCode Problem

Find the Maximum Achievable Number

Problem Statement

In one operation independently increase or decrease x by 1 and simultaneously increase or decrease num by 1. Return the largest initial x that can become equal to num after at most t such operations.

Source: Find the Maximum Achievable Number on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
num = 4, t = 1
Output
6

# Example 2

Input
num = 3, t = 2
Output
7

Constraints

1 <= num, t <= 50

Related LeetCode Problems

Practice more problems similar to Find the Maximum Achievable Number.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.