5

Why is it faster to pass string by reference then by value?

 2 years ago
source link: http://codeforces.com/blog/entry/101759
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

When i was submitting my solution in leetcode, I was getting TLE when passing string by value but after changing it to string by reference it got faster. I thought strings were passes by refence automatically anyways. Below are images of code being accepted and not accepted.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK