携程笔试 2019.4

1.判断链表是否有环(用的是ArrayList 中 contains方法)

public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    String s = scanner.nextLine();
    String[] str = s.split(",");
    boolean flag = false;
    ArrayList list = new ArrayList();
    for(int i=0;i

2.反转链表

  输入:

  [1,2,3,4]

  2

输出: 

 [2,1,4,3]

public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    String s = scanner.nextLine();
    int k = scanner.nextInt();
    s=s.replace("[","").replace("]","");
    String[] str =s.split(",");
  Demo6 test = new Demo6();
    test.method(str,k);
System.out.print("[");
   for(int i=0;i

3. (通过 71%

输入:2  /order/print/printlist  /order/print/printlist

输出: 111 121

 

输入:3 /order/print/printlistlist/printlist  /order/print/printlistlist/printlist /order/print/printlistlist/printlist

输出:1111 1221 1331

public static void main(String[] args) {
      Scanner scanner = new Scanner(System.in);
      int num = scanner.nextInt();
   String s = scanner.next();
      String[] ss = new String [num];
      Demo5 test = new Demo5();
      HashMap map = new HashMap();
      for(int i=0;i map){
      String[] strs = s.split("/");
      String result ="";
      if(strs.length==1){
          return "";
      }
      for(int i=1;i

 

你可能感兴趣的:(实习)