Recently I made a very simple challenge:
Change the value of two variables without using a third variable.
int a = 5;
int b = 3;
a += b; // a = 8
b = a - b; // b = 5;
a -= b; // a = 3;
It is simple because they are arithmetic operations.
But I was wondering how to do it if they were strings .
string a = 'Stack';
string b = 'Overflow';
I've even thought of some solutions, but these apply to #
Example JS
var a = 'Stack';
var b = 'Overflow';
a = a+'|'+b; // a = 'Stack|Overflow';
a = a.split('|'); // a = ['Stack', 'Overflow'];
b = a[0]; // b = 'Stack';
a = a[1]; // a = 'Overflow';
How could you solve this challenge with string ?