Why is it faster to pass string by reference then by value?
Разница между en1 и en2, 148 символ(ов) изменены
When i was submitting one my solutions 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.
↵
↵
![ ](/predownloaded/09/29/0929aaf1c5323a569c2c0f1b80177424a9f984f3.jpg)↵
![ ](/predownloaded/64/31/643150bdf9a12db0b77441497ccc99b4140aaba9.jpg)

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en3 Английский PrasoonJha 2022-04-09 15:28:19 5 Tiny change: 'ubmitting one my solutions in leetco' -> 'ubmitting my solution in leetco'
en2 Английский PrasoonJha 2022-04-09 15:27:38 148
en1 Английский PrasoonJha 2022-04-09 15:19:14 340 Initial revision (published)