A desktop-style app bar has nested menus. Each menu item is { label } or { label, children }, where children is an array of more items. An item with no children key, or an empty children array, is a command the user can click.
Write menuPaths(items) that returns the full path of every clickable command, written as labels joined by " > ", such as "File > Open > Recent".
List the paths in depth-first order: an item's commands come before the next item at the same level, and siblings keep their order.
Input: items = [{"label":"File","children":[{"label":"New"},{"label":"Open","children":[{"label":"Recent"},{"label":"Browse"}]}]},{"label":"Help"}] Output: ["File > New","File > Open > Recent","File > Open > Browse","Help"]
Open has children, so it isn't a command itself; its two children are.
Input: items = [] Output: []
An empty menu has no commands.
100,000 items in total.20 levels deep." > ".Run tries your code on the examples. Submit runs every test, including hidden edge cases and big inputs that check your code is fast enough, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #4 Menu Breadcrumb Paths. 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.