Panda Guru LogoPanda
Guru

PLUM HQ | SE3 | Backend | Interview Experience | Jan 2025 | Rejected

Round 1

Questions:

  1. Problem 1: Car Fleet
    My solution: Accepted in one go: Submission

  2. Problem 2: Course Schedule
    My solution: Accepted in one go: Submission

Candidate's Approach

No approach provided.

Interviewer's Feedback

No feedback provided.


Round 2

Questions: Problem Statement:
You have a spreadsheet with a maximum of 26 rows and a maximum of 9 columns. The rows are labeled A-Z and the columns are numbered 1-9. Each cell is identified by its row label followed by its column number.

| Spreadsheet | 1 | 2 | 3 | 4 | |-----------|-----------|-----------|-------|-------| | A | 9 | A1 + C2 / D3 | 5 | B4 | | B | 4 | -10 | A3 + D3 | 6 | | C | -23 | 2 | 9 | A1 * B2 | | D | A4 | 0 | -10 | B3 |

Each cell in the spreadsheet either has a value (a decimal number), or a formula which can be used to compute its value. The formula is an expression with the four standard binary operators (+, -, *, /), and operands as either decimal numbers, or other cell identifiers.

Please implement the following in a programming language of your choice

ClassName: Spreadsheet
Constructor:

Methods:

Adding my Code

I find this question really frustrating and not useful to ask in a coding interview. Interviewer neither shared what exactly he is looking for. Is it a problem-solving round or a machine coding round?

I lose interest to solve the problem and thus just did whatever I can to spend 1 hour. (I don't regret what I did).
The below solution is incomplete and just what I implemented.

// Online Java Compiler // Use this editor to write, compile and run your Java code online class Main { private static double [][] results; private static double [][] dp; public static void main(String[] args) { String[][] sheet = { {"9", "A1 + C2 / D3", "5", "B4"}, {"4", "-10", "A3 + D3", "6"}, {"-23", "2", "9", "A1 * B2"}, {"A4", "0", "-10", "B3"} }; initializeResults(sheet); System.out.println(getValue("A1")); //System.out.println(getValue()); } // Assumptions to skip validations // Assuming [A-Z] public static double getValue(String cell) { return results[getRow(cell)][getCol(cell)]; } private static void initializeResults(String[][] sheet) { results = new double[26][9]; int rows = sheet.length; int cols = sheet[0].length; // dp = new double[rows][cols]; for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { results[i][j] = evaluate(sheet[i][j]); } } } private static String[] precedence = {"/", "*", "+", "-"}; private static double evaluate(String cellVal) { String[] ele = cellVal.split(" "); if (ele.length == 1) { return getVal(ele[0]); } String[] tempScan = ele; for (int i = 0; i < precedence.length; i++) { if (tempScan.contains(precedence[i])) { tempScan = evaluateOperator(tempScan, precedence[i]); } } return getVal(tempScan[0]); } private static double getVal(String ele) { char c = ele.charAt(0) - '0'; if (c < '0' || c > '9') return evaluate(sheet[getRow(ele)][getCol(ele)]); else return Double.parseDouble(ele); } private static String[] evaluateOperator(String[] ele, String operator) { Stack<String> st = new Stack(); for (int i = 0; i < ele.length; i++) { if (ele[i].equals(operator)) { double second = getVal(ele[i + 1]); double first = st.pop(); st.add(calculate(first, second, operator)); i++; } else if (isOperator(ele[i])) { st.add(ele[i]); } else { st.add(getVal(ele[i])); } } // Convert stack to array String[] temp = new String[stack.size()]; for (int i = stack.size() - 1; i >= 0; i--) { temp[i] = stack.pop(); } return temp; } private static boolean isOperator(String ele) { if (ele.equals("/") || ele.equals("*") || ele.equals("-") || ele.equals("+")) { return true; } return false; } private static double calculate(String first, String second, String operator) { if (operator.equals("/")) { return Double.parseDouble(first) / Double.parseDouble(second); } if (operator.equals("*")) { return Double.parseDouble(first) * Double.parseDouble(second); } if (operator.equals("+")) { return Double.parseDouble(first) + Double.parseDouble(second); } return Double.parseDouble(first) - Double.parseDouble(second); } private static int getRow(String cell) { char c = cell.charAt(0); return c - 'A'; } private static int getCol(String cell) { char c = cell.charAt(1); return c - '1'; } }
Candidate's Approach

The candidate expressed frustration with the question, feeling it was not useful for a coding interview. They mentioned that the interviewer did not clarify whether it was a problem-solving or machine coding round, which led to a loss of interest in solving the problem. The provided solution is incomplete and reflects only what the candidate could implement within the time limit.

Interviewer's Feedback

No feedback provided.