I'm not a big fan of using Leetcode and Leetcode-like question-banks for interviews. I like creating my own questions that fit the purpose, run them by a lot of my smart friends and colleagues, and use them in interviews. There are multiple reasons why I'd do this.
Problem | Category |
---|---|
Given two arrays, each representing the BFS and DFS traversals of a binary tree, construct the binary tree.
Input:
BFS Array: {3,1,6,7,4}
DFS Array: {4,1,3,6,7}
|
Logic, Data Structures |
Make 'm' using 'n' 'l's. List of operations is provided. Unary (factorial, decimal), binary (sum, difference, multiply, divide etc.) operators.
As an extension, also include concatenation operator.
Example:
|
Logic, Implementation |
Card Punch
A software firm figures out that one of the employees is swiping another employee's id along with hers, while entering the office, all 5 days of the week. They want to find out who's doing it. Given are the 5 arrays of the order in which employees swiped their cards while entering office from Monday to Friday. If a person is swiping someone else's card as well, then two numbers should be appearing in adjacent order in all five arrays. If the numbers don't appear adjacent in all 5 arrays, then it might not be a fraud case as people doing car pooling or neighbors often swipe one after the other, however, not all five days of the week, they come together. Find those numbers given 5 arrays of size 10,000 (for 10000 employees) in O(n).
|
Logic |
Nibble Swap
Given a number, swap the nibbles from right to left and return the final number.
|
Implementation, Edge cases, System knowledge |
Poona Number A Poona number is defined as a number that, when written in words in English and the order of its letters in the English alphabet are added, equals the same number! For example, Sum of orders of the letters of "one" = 15 + 14 + 5 = 34, which is not equal to 1. Thus, 1 is not a Poona number. Sum of orders of the letters of "one hundred" = 108, which is a bit more than 100. So, 100 is also not a Poona number. There are only two Poona numbers*. Could you find them?
*When writing in words, the British system is followed where there is an "and" after hundreds, and an "and" after thousands with no hundreds.
|
Implementation, Efficiency, Numerical |
What does this algorithm do? What is its efficiency? For what all cases would it fail? (There are no compilation issues) How do you fix the issues?
private void whatDoIDo(int... input) {
|
Debugging, Fixing, Code refactoring and clean-up, Naming |
Data Structure/Data Model Design
Design the data model and APIs (call elevator) for a 100 floor building which has 10 elevators.
|
Design, Edge cases, Comprehensiveness, Scalability |
Fermi question - Versioned compiler
If there is a compiler that stores the previous value of any variable or execution stack by default, what effect will it have on sorting?
|
Extrapolation, Creativity, Applicability, Discussion, Comprehensiveness |
h-Depth Index
We all know that the h-index of an author is the maximum value of h such that the given author has published at least h papers that have each been cited at least h times.
Given an array of length l whose elements represent number of citations for an author, and then given l arrays each representing the h-index of authors citing those papers, calculate the h-Depth index of the author.
|
Logic, Implementation |
Password Incorrect! Please try again!!
Given the below rules, write a function to:
|
Edge cases |
Create data model for Rubik's Cube and create a backtracking solution (not necessarily optimal) for solving the same. | Data Structure, implementation, optimization |
Towers of Hanoi but with a variable number of auxiliary poles. The number of auxiliary poles is given in the input. (Instead of just one aux pole in the standart Towers of Hanoi problem). | Logic, Implementation |
Uprooting!
Convert an ascending binary search tree whose root node has the minimum value, to a descinding binary search tree whose root node is the maximum value in place, without extra space (other than constant spaces)
|
Data structure, logic, implementation |
How do you multiply two million-digit integers? Assume the integers are in a file.
Write a function to multiply two million-digit numbers, and provide a way to interpret the result of multiplication.
|
Data Structure, implementation |
Find the aircraft debris in the ocean
An image matrix of the top view of an ocean, and of size mxn whose elements are all integers is given.
|
Dynamic Programming, logic, implementation |
Minimum number of primes adding up to n
Given a number `n`, find the minimum number of primes (and primes themselves) adding up to `n`.
|
Math, Dynamic Progamming, Logic |
Employee ID
Jane works at E.F. Capital LLC, a Manhattan based algorithmic trading firm. E.F. Capital is a fairly small firm, and it issues Employee ID cards serially from 1 to total number of employees at any point. Jane notices that the product of all the EmployeeID numbers before her is the same as the product of all the EmployeeID numbers after her!
|
Logic, implementation, efficiency |
Month Day Combination
Two arrays are given, each having integers between 1 and 31 both inclusive.
|
Logic |
Determinent of a Matrix Find the max possible value configuration and the min possible value configuration for a 3x3 matrix given its 9 elements.
Example:
|
Logic, Implementation, Efficiency |
Restaurant Owner's Problem
A restaurant in a remote island has a lot of corrupt waiters who charge their customers less for the food and take a part of the saved money into their personal pockets. The owner wants to combat the waiters' fraudulent practices of billing for lesser money. So, he sets the price of all items in the menu to prime numbers and enforces a maximum of four items per check.
|
Logic |
Linked List to Binary Tree in-space
Given a LinkedList and the LinkedList Node class, change the class and convert the linkedlist "in-space" to a binary tree.
|
Data Structure, Implementation |
(Cricket Related - might not be universally applicable) Cricket Scorecard Simulation
Simulate a cricket scorecard from batting and bowling perspective
|
Simulation, Design, Testing, Sample Data |
Number to Words
Given a number, print the word in standard English words
|
Logic, edge cases. Solution |
Valid email address. Extension: Check if valid business email
Check if a given email address is a valid format email address.
|
Edge cases, testing |
Base Conversion
Validate and then convert a given number from source base to destination base.
|
Implementation, Edge Cases |
A company's org chart is represented in the form of a tree. Children of a node are reportees of the value of the node. Direct reportees are direct children, indirect reportees are children of children nodes Leaves are individual contributors. Root node is the CEO. Given the above, implement tree adjustment in cases of: 1. Promotion: In case of a promotion, the node of the promoted employee starts reporting to parent's parent. All the peers start reporting to the promoted employee. 2. Termination: In case of termination, all reportees start reporting to terminated employee's manager. 3. On promotion or termination, no manager (except the CEO) has more than 5 reportees. If they do, promote least number of nodes such that it isn't the case anymore |
Data structure, implementation, logic |
Binary Tree Sum
Given a binary tree (not a binary search tree) with nodes whose values are integers, find the subtree with the largest sum.
|
Data Structure, logic, implementation |
Year 2000. Two supercomputers running JVM were being used by Bank of Lovindale, the largest mid-western bank for interest calculation on all of its customer loans. Surprisingly, even for the same amount of principle and same rate of interest, and similar time period, the two super computers gave different results. Though the difference was minor, when added across all the branches of the bank and across all customer loans, the bank deduced the differene might be sizeable. However, the contractor who had written the program audited their software/program multiple times and confirmed there is no bug in the program. Eventually, a developer noticed that the programs are being run on different machines with different processors, one on x87 based processor and another on an in-house Proc processor, and identified the issue. If you were that developer from 2000, how would you analyze this issue and how would you fix it?
Hint: The answer is one word.
|
Debugging, programming language, investigation |
Sorting algorithms for different scenarios
What is the best sorting algorithm (in terms of time efficiency) for sorting...
|
Discussion, Thinking, Depth, Logic |
Implement an advanced datastructure in Java Skiplist or hyperloglog or bloom filter Explain the candidate how algorithm works and ask them to implement |
Onboarding, programming language, data structures, edge cases |
Given a graph of objects as nodes and all the dependencies of each node represented as the node's edges representing the memory of JVM, implement the mark-and-sweep garbage collector.
Implementation, Logic
|
|
Implement a simple Kafka-esque distributed queuing system. Includes a producer, a broker, and a group of consumers The idea of this question is that while Kafka can be notoriously hard to implement for Availability, Redundancy, and Scale, the core of Kafka is pretty straight-forward with minimal yet interesting concepts.
The producer produces the messages in different topics.
|
Implementation, edge cases |
The developers from the infrastructure team want an issue to be debugged by the platform development team. The company being old school with no central debugging solutions, the infra team simply wants to send the serialized object of a class which holds the key to the issues to the platform team. However, the class being a little sensitive, the infra team wants to serialize only those members of the class which are not customer specific. How do they selectively serialize it?
Hint: The answer is one word.
|
Investigation, language specific |