Round 3 – Technical Interview
The third technical round further assessed my coding and problem-solving prowess. The questions asked in this round are listed below:
- Calculating the minimum number of steps necessary to traverse an array and reach its end.
Java
public class MinimumJumpsToEnd { public static int minJumpsToEnd( int [] arr) { int n = arr.length; if (n <= 1 ) { return 0 ; // 1 element or is empty, no jumps needed } int jumps = 1 ; int maxReach = arr[ 0 ]; // max reach from the first position int steps = arr[ 0 ]; // steps available from the first position for ( int i = 1 ; i < n; i++) { if (i == n - 1 ) { return jumps; // reached the end } maxReach = Math.max(maxReach, i + arr[i]); // Update max reach steps--; if (steps == 0 ) { if (i >= maxReach) { return - 1 ; // Can't proceed further } jumps++; steps = maxReach - i; } } return - 1 ; // end not reachable } public static void main(String[] args) { int [] arr = { 2 , 3 , 1 , 1 , 4 }; System.out.println(minJumpsToEnd(arr)); } } |
2
- Given two strings, find the length of their longest common subsequence. A subsequence is a sequence that appears in the same relative order in both strings, but not necessarily consecutively. For example, for the strings “ABCD” and “ACDF”, the longest common subsequence is “ACD”, with a length of 3.
Java
public class LongestCommonSubsequence { public static int longestCommonSubsequenceLength(String str1, String str2) { int m = str1.length(); int n = str2.length(); // a table to store the lengths of longest common // subsequences int [][] dp = new int [m + 1 ][n + 1 ]; // fill the table using dp for ( int i = 1 ; i <= m; i++) { for ( int j = 1 ; j <= n; j++) { if (str1.charAt(i - 1 ) == str2.charAt(j - 1 )) { dp[i][j] = dp[i - 1 ][j - 1 ] + 1 ; } else { dp[i][j] = Math.max(dp[i - 1 ][j], dp[i][j - 1 ]); } } } return dp[m][n]; } public static void main(String[] args) { String str1 = "ABCD" ; String str2 = "ACDF" ; int result = longestCommonSubsequenceLength(str1, str2); System.out.println( "Length of longest common subsequence: " + result); } } |
Length of longest common subsequence: 3
Loyalty Juggernaut Interview Experience for Product Engineer Role
I applied to Loyalty Juggernaut through the AngelList website and received a call from their HR shortly after to discuss interview scheduling. Given that I was in my 6th semester with the on-campus placement drive approaching, I decided to explore my options. Nonetheless, I proceeded with the interview rounds to gain valuable experience.