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

Interview Question

Financial Software Developer Interview New York, NY

How to reverse a string by word like "I love California" to

  "California love I"
Tags:
technical, algorithm
Answer

Interview Answer

1 Answer

0

If they are looking for an answer using a data structure, use a stack. Assuming it is a high-level language question:
- Separate words by delimiter (be sure to ask what delimiter to use first! Don't assume)
- Push in order onto a stack
- Pop off the stack into a string buffer, or just print

Mikhail on Oct 9, 2012

Add Answers or Comments

To comment on this, Sign In or Sign Up.