情感测试
情感测试

您现在的位置: 情感测试简介_情感测试玩法 > 情感测试简介 > 6月20日每日一题皇位继承顺序

6月20日每日一题皇位继承顺序

发布时间:2021-8-20 12:58:49   点击数:

题目名称:皇位继承顺序

难度:中等

题目描述:

示例输入:["ThroneInheritance","birth","birth","birth","birth","birth","birth","getInheritanceOrder","death","getInheritanceOrder"][["king"],["king","andy"],["king","bob"],["king","catherine"],["andy","matthew"],["bob","alex"],["bob","asha"],[null],["bob"],[null]]输出:[null,null,null,null,null,null,null,["king","andy","matthew","bob","alex","asha","catherine"],null,["king","andy","matthew","alex","asha","catherine"]]解释:ThroneInheritancet=newThroneInheritance("king");//继承顺序:kingt.birth("king","andy");//继承顺序:kingandyt.birth("king","bob");//继承顺序:kingandybobt.birth("king","catherine");//继承顺序:kingandybobcatherinet.birth("andy","matthew");//继承顺序:kingandymatthewbobcatherinet.birth("bob","alex");//继承顺序:kingandymatthewbobalexcatherinet.birth("bob","asha");//继承顺序:kingandymatthewbobalexashacatherinet.getInheritanceOrder();//返回["king","andy","matthew","bob","alex","asha","catherine"]t.death("bob");//继承顺序:kingandymatthewbob(已经去世)alexashacatherinet.getInheritanceOrder();//返回["king","andy","matthew","alex","asha","catherine"]提示:1=kingName.length,parentName.length,childName.length,name.length=15kingName,parentName,childName和name仅包含小写英文字母。所有的参数childName和kingName互不相同。所有death函数中的死亡名字name要么是国王,要么是已经出生了的人员名字。每次调用birth(parentName,childName)时,测试用例都保证parentName对应的人员是活着的。最多调用10^5次birth和death。最多调用10次getInheritanceOrder。来源:力扣(LeetCode)链接:

转载请注明:http://www.zmax-alibaba.com/qgjj/138004.html

网站简介 | 发布优势 | 服务条款 | 隐私保护 | 广告合作 | 合作伙伴 | 版权申明 | 网站地图

当前时间: