The Prime Subtraction Operation problem asks whether you can make an array strictly increasing by subtracting a prime from each element (at most once). For each element, you can optionally subtract any prime p < element to make the array strictly increasing. This coding problem uses binary search over precomputed primes. The array, math, number theory, binary search, and greedy interview pattern is the core.
Microsoft, Amazon, Google, and Bloomberg ask this because it tests greedy thinking with number theory: for each element, find the largest prime you can subtract (to make it as small as possible) while keeping it greater than the previous element.
Greedy + precomputed primes + binary search. Precompute all primes up to max element using Sieve of Eratosthenes. Process elements greedily left to right: for each arr[i], find the largest prime p < arr[i] such that arr[i] - p > previous value. Use binary search on the sorted primes list. If no valid prime exists and arr[i] <= previous value, return false.
arr=[4,9,6,10]. prev=0.
Prime Subtraction combines Sieve of Eratosthenes with greedy binary search. The greedy insight: always subtract the largest valid prime (maximizes decrease while satisfying constraint). Binary search on sorted primes gives the optimal choice in O(log(max_prime)) per element. Practice problems combining prime generation with greedy array operations — they appear in optimization and scheduling contexts.