Skip to main content
Back to problems
#2769
Easy Algorithms

Find the maximum achievable number

Math
91.2% acceptance
Feb 25, 2026
518
768
Given two integers, num and t. A number x is achievable if it can become equal to num after applying the following operation at most t times: Increase or decrease x by 1, and simultaneously increase or decrease num by 1. Return the maximum possible value of x.

Solution

Rust
Time O(1)
Space O(1)
LeetCode
solution.rs
impl Solution {
  pub fn the_maximum_achievable_x(num: i32, t: i32) -> i32 {
    num + 2 * t
  }
}