sumDouble
Given two int values, return their sum. Unless the two values are the same, then return double their sum.
Examples
sumDouble(1, 2) → 3
sumDouble(3, 2) → 5
sumDouble(2, 2) → 8
Starter code
function sumDouble(a, b) {
}
Complexity of the optimal solution
Time O(1), space O(1). The solution involves a single conditional check and basic arithmetic. These operations take a constant amount of time. It uses no extra memory that scales with input size.