A navigation component stores the breadcrumb trail as an array of page names, from the home page to the current page. A new "back to start" view needs them in the opposite order.
Write reverseTrail(crumbs) that reverses crumbs in place, without creating a second array and without calling reverse. The tests check crumbs after your function runs.
Input: crumbs = ["Home","Shop","Shoes","Running"] Output: ["Running","Shoes","Shop","Home"]
The last crumb becomes the first, and so on.
Input: crumbs = ["Home","Docs","API"] Output: ["API","Docs","Home"]
With an odd count, the middle crumb Docs stays put.
0 <= crumbs.length <= 100000Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #98 Reverse a Breadcrumb Trail. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.