海康威视笔试vue9.14
想不通为什么深搜有问题,求某佬指点一下...
function findNode(tree, target) {
if (tree.name === target) {
return tree.val;
}
if (tree.children) {
for (const child of tree.children) {
const result = findNode(child, target);
if (result) {
return result;
}
}
}
return null;
}
// 输入的树结构
const tree = {
val: 'rootVal',
name: 'rootName',
children: [
{
val: 'childVal',
name: 'childName',
children: [
{
val: 'child1-1Val',
name: 'child1-1Name'
}
]
},
{
val: 'child2Val',
name: 'child2Name'
}
]
};
// 输入的目标节点名称
const target = 'rootName';
const result = findNode(tree, target);
console.log(result);
function findNode(tree, target) {
if (tree.name === target) {
return tree.val;
}
if (tree.children) {
for (const child of tree.children) {
const result = findNode(child, target);
if (result) {
return result;
}
}
}
return null;
}
// 输入的树结构
const tree = {
val: 'rootVal',
name: 'rootName',
children: [
{
val: 'childVal',
name: 'childName',
children: [
{
val: 'child1-1Val',
name: 'child1-1Name'
}
]
},
{
val: 'child2Val',
name: 'child2Name'
}
]
};
// 输入的目标节点名称
const target = 'rootName';
const result = findNode(tree, target);
console.log(result);
全部评论
兄弟,试试光伏电池行业~
相关推荐
2025-12-09 23:27
商丘学院 嵌入式软件工程师
程序员花海:实习和校招简历正确格式应该是教育背景+实习+项目经历+个人评价 其中项目经历注意要体现业务 实习经历里面的业务更是要自圆其说 简历模板尽可能保持干净整洁 不要太花哨的 点赞 评论 收藏
分享
2025-11-18 20:04
泉州职业技术大学 算法工程师
专业嗎喽:个人信息名字太大,合到电话邮箱那一栏就行,有党员写过党,剩下其他全删,站空太大了
把实习经历丰富,放最前面,然后是个人评价,技能之类的,然后是学校信息。项目经历最后面,可以就选一个自己擅长的。
现在是学校不是92就扣分的,没必要放前面。
然后现在看重实习经历>竞赛经历(校园经历)>课程项目经历 点赞 评论 收藏
分享
