Swap two variables using temp
Java
Easy
5 views
Problem Description
Task: swap two integers a and b and return as array [b,a].
Output Format
Return value
Constraints
Use temp variable.
Official Solution
static int[] swapWithTemp(int a,int b){int t=a;a=b;b=t;return new int[]{a,b};}
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!