题解 | #查找两个字符串a,b中的最长公共子串#

配置文件恢复

http://www.nowcoder.com/practice/ca6ac6ef9538419abf6f883f7d6f6ee5

while(commands = readline()) {
  const arr = commands.split(" ");
  let command = "unknown command"
  if(arr.length === 1) {
    if('reset'.startsWith(arr[0])) {
      command = "reset what"
    }
  } else if(arr.length === 2) {
    const prev = arr[0];
    const next = arr[1];
    let resetCount = 0;
    if('reset'.startsWith(prev) && 'board'.startsWith(next)) {
      command = 'board fault'
      resetCount++;
    } 
    if ('reboot'.startsWith(prev) && 'backplane'.startsWith(next)) {
      command = 'impossible'
      resetCount++;
    }
    if ('board'.startsWith(prev) && 'add'.startsWith(next)) {
      command = 'where to add'
      resetCount++;
    }
    if ('board'.startsWith(prev) && 'delete'.startsWith(next)) {
      command = 'no board at all'
      resetCount++;
    }
    if ('backplane'.startsWith(prev) && 'abort'.startsWith(next)) {
      command = 'install first'
      resetCount++;
    }
    if(resetCount > 1) {
      command = "unknown command"
    } 
  }
  console.log(command)
}
全部评论

相关推荐

评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务