Microsoft interview question

Write a function that reverses an array.

Interview Answers

Anonymous

Jan 6, 2018

What areas did the Skype interview cover?

2

Anonymous

Dec 19, 2017

I wrote my function in C++, using a std::vector instead of a C array. The reversal is performed in-place using iterators. template void reverse(std::vector& v) { if (v.size() > 1) for (auto i1 = v.begin(), i2 = v.end() - 1; i1 < i2; ++i1, --i2) std::iter_swap(i1, i2); }