Branch.io Phone screen | Senior developer Android
Anonymous User
400

I had 1 hour Phone screen. Interviewer was super nice, he asked me introduction, background and bunch of Android related question and an DS algorithm question.


/*
 * Click `Run` to execute the snippet below!
 */

import java.io.*;
import java.util.*;

/*
 * To execute Java, please define "static void main" on a class
 * named Solution.
 *
 * If you need more classes, simply define them inline.
 */

/**
1,...60, 120,...1440 min / day 0..1439

int[] train1 = [ 1100, 360, 580, 970, 220, ... ]
int[] train2 = [ 220, 630, 770, 360, 1250, ... ]

compute times both trains arrive at the same time 


*/

class Solution {
  public static void main(String[] args) {
    ArrayList<String> strings = new ArrayList<String>();
    strings.add("Hello, World!");
    strings.add("Welcome to CoderPad.");
    strings.add("This pad is running Java " + Runtime.version().feature());

    for (String string : strings) {
      System.out.println(string);
    }
    
    int[] train1 = {1100, 360, 580, 970, 220, 1440, 110};
    int[] train2 = {220, 630, 770, 360, 1250, 221, 1440, 110};
    findTrainIntersaction(train1, train2);
  }
  
  public static Set<Integer> findTrainIntersaction(int[] train1, int[] train2) {
    
    Set<Integer> ans = new HashSet<>();
    boolean[] arr = new boolean[1441];

    for(int i=0; i<train1.length;i++) { 
      arr[train1[i]] = true;
    }
    
    for(int i=0;i<train2.length;i++) {
      if(arr[train2[i]]) {
        System.out.println(train2[i]);
        ans.add(train2[i]);
      }
    }
        
    return ans;
  }
}
Comments (1)