Pergunta de entrevista da empresa Maruti Suzuki

Swap two numbers without using third variable

Resposta da entrevista

Sigiloso

11 de set. de 2024

// Let the two numbers be a and b a = a + b; // Step 1: Add both numbers b = a - b; // Step 2: Subtract b from the sum to get a a = a - b; // Step 3: Subtract the new b from the sum to get b