亚马逊笔试题目_亚马逊笔试题第二弹

笔经面经分享之亚马逊笔试题第二弹。希望通过本帖,能够对正在找工作的同学或者将要找工作的同学提供微薄之力。

--小站小编

1笔试题

下面是来自于亚马逊的编程笔试题,感兴趣的同学可以先自己想想解题思路:

Please implement a simple logic rule, the input is a set of logic formula, the format is like a1,a2,a3,…,an->b, which means a1,a2,a3,…an can deduce b. It meets the following rules:

1.If A->B B->C then A->C

2.If A,B->C D->A then D,B->C

3.If A,B->C then B,A->C

The input contains two lines:

1.The first line contains n (100>n>0) base formulas, separated by spaces

2.The second line contains m (100>m>0) formulas that need to check true or false according to above n formulas, separated by spaces

The output should be m lines, if the i-th formula in the second line can be deduced by the n base formulas, the i-th line should be "true", otherwise, "false".

Each element is a case sensitive alphabet, to simplify the parsing work, “->” is replaced by ">", there might be more than 1 character on the left side and only one on the right side, the following is an example:A,B,C>D

Sample Input and Output

Input

A>B B>C

A>C

Output

true

Input

A,B>C D,E>A E>B

E,D>C F,E>C

Output

true

false

Input

A>B A,B>C

A>C

Output

true

Please complement thematchRulemethod inSolutionclass:

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

public class Solution {

public static void main(String[] args) throws IOException {

InputStreamReader isr = new InputStreamReader(System.in);

BufferedReader br = new BufferedReader(isr);

String baseRules = br.readLine();

String checkingRules = br.readLine();

matchRule(baseRules, checkingRules);

br.close();

isr.close();

}

private static void matchRule(String baseRules, String checkingRules) {

}

}

--------------我是华丽丽的分隔线----------------

2图简介

首先让我们对比一下几种数据结构:线性表&#x

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值