【发布时间】:2021-09-16 09:42:24
【问题描述】:
需要以下给定输出格式的输入。我该如何为此使用蛮力方法和动态编程方法?我试过了,但不知道如何继续。
输入
[
"Application/Calendar",
"Application/Chrome",
"Application/Webstrom",
"Application/Photoshop",
"Application/firefox",
"Documents/Material-UI/src/index.js",
"Documents/Material-UI/src/tree-view.js"
]
输出
[
{
"name": "Application",
"children": [
{
"name": "Calendar",
"children": []
},
{
"name": "Chrome",
"children": []
},
{
"name": "Webstrom",
"children": []
},
{
"name": "Photoshop",
"children": []
},
{
"name": "firefox",
"children": []
}
]
},
{
"name": "Documents",
"children": [
{
"name": "Material-UI",
"children": [
{
"name": "src",
"children": [
{
"name": "index.js",
"children": []
},
{
"name": "tree-view.js",
"children": []
}
]
}
]
}
]
}
]
【问题讨论】:
-
请阅读Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers? - 总结是这不是解决志愿者的理想方式,并且可能会适得其反。请不要将此添加到您的问题中。
标签: recursion dynamic-programming backtracking