I had my Meta phone screen round recently. I was asked the below 2 questions:
public String customSortString(String order, String s) {
Map<Character, Integer> map = new HashMap<>();
int n = s.length();
int m = order.length();
for(int i=0; i<n; i++)
{
char letter = s.charAt(i);
map.put(letter, map.getOrDefault(letter,0)+1);
}
StringBuilder result = new StringBuilder();
for(int i =0; i<m; i++)
{
char letter = order.charAt(i);
if(map.containsKey(letter))
{
int count = map.get(letter);
while(count-- > 0)
{
result.append(letter);
map.put(letter,count);
}
}
}
for(char key : map.keySet())
{
int count = map.get(key);
while(count > 0)
{
result.append(key);
count--;
}
}
return result.toString();
}public static int minFlightCost(int[] D, int[] R) {
int n = D.length;
int minDep = Integer.MAX_VALUE;
int minRT = Integer.MAX_VALUE;
for (int i = 0; i < n; i++) {
if (i > 0) {
minRT = Math.min(minRT, minDep + R[i]);
}
minDep = Math.min(minDep, D[i]);
}
return minRT;
}Interview Format: It is a 45 mins round set for 2 programming questions only.
I was asked the time and space complexity with justifications and to walk through the code with an example, also the edge cases and how will they be handled.
Also, can anyone with experience share me to the onsite round format, tips and typical questions to practice please?