Bloomberg L.P. Interview Question: How to reverse a string... | Glassdoor

Interview Question

Software Engineer Intern Interview(Student Candidate) New York, NY

How to reverse a string


Interview Answer

2 Answers


using two pointers, and the first pointing to the beginning, and the other pointing to the end, and both move to the middle, and do the swapping in the meantime.

Interview Candidate on Jan 31, 2012

Java: return new StringBuilder(inputString).reverse().toString();
C++: return string(inputString.rbegin(), inputString.rend());

Saeid on Dec 19, 2015

Add Answers or Comments

To comment on this, Sign In or Sign Up.