+ 5
[ASSIGNMENT] String swap
Write a code where you swap the value of two strings without using a third variable. Note:codes involving conversion of string to ASCII values are disqualified
11 Answers
+ 4
best codes so far,in relation to complexity
https://code.sololearn.com/ccW1v62w4qk0/?ref=app
https://code.sololearn.com/c1SPQxq59Jh0/?ref=app
+ 20
Swap two strings with and without
third variable && show the time spent to solving the task! đđđ
https://code.sololearn.com/c24Tb04EO0PQ/?ref=app
+ 9
Hi đłđŹBrains
Can I do that
https://code.sololearn.com/cm0yKxnys7xZ/?ref=app
+ 9
I did it two different ways.
https://code.sololearn.com/cIU5mT1NJpqw
+ 6
python's solution is easy AF!!
+ 4
There's a built-in swap() function in C++. Time to solve ~1min:
https://code.sololearn.com/cPgo477jb414/?ref=app
In C it would have been more of a challenge.
+ 3
Here's my solution using XOR.
Programmed in C:
https://code.sololearn.com/c1SPQxq59Jh0/#c
I couldn't work out what you meant by not converting to ASCII values! The strings in C are already ASCII based arrays! Anyway, no conversion occurs.
+ 3
yes favour I know,its pretty much too easy
+ 2
I still love the Python answer though, as it's a reminder that a complex task in one programming language can be easy in another, and vice versa đ
+ 2
in c++ you can use function strrev() which comes under string.h header file
+ 1
nonzyro Yes, I think some challenges, need to specify the language. Example, if the challenge was to create a list library, it would be much harder in C than Java etc!