Interview Preparation II
* Write an algorithm to Reverse Linked list.
* Find an element in a NxM matrix of elements with partial "top-down + left-right" ordering. (divide & conquer)
* Find K most common words in a file (HashMap)
* Check if a linked list has a cycle (tortoise & hare)
* Generate all subsets of a set, with some constraint (recursion)
* Find a rational number approximating a floating point number with error less than epsilon (euclid)
Graph questions regarding level order traversal of a graph.
Missing numbers question.
2 sum problem.
Design patterns.
Functional Interface.
Lamda Expressions.
Minheap and maxheap.
Binary tree basics.
Decorator Design Pattern.
http://www.cnblogs.com/coffeeSS/p/5405787.html
Abstraction,Encapsulation,HashMap,HashTable.
what is final, what is its implication on method,class and variable?
What is the root class of java ?
Tell me some of the main methods of Object class you know?
What does the method NotifyAll() does ?
What is the use of concurrentHashMap() in multithreading?
What are different kind of Indexes in SQL? https://msdn.microsoft.com/en-us/library/ms175049(v=sql.105).aspx
What are difference between DELETE and TRUNCATE in SQL?
Sudo code for Fibonacci Numbers
EJB concepts
why struts?
how to find square root of integer
JPA implementations other than hibernate
How to prevent livelocks in java threading
How do you find 2 missing elements in an array of consecutive integers that are not sorted who's size is N-2.
How do you calculate weighted averages?
What is the concurrent mark-sweep alogirthm for garbage collection?
About joins - inner join,outer join,left,right joins.
Stored procedures.
hasmaps concepts,externalization,double linked lists etc
stored procedures have better performance than functions .. because stored procedures are compiled and stored at server side.. then he asked me about execution of storage procedure..
What is Object Oriented programming? What is the difference between OO and process oriented?
Given a 8x8 chess board what is the cumulative probability that next move will fall in the chess board.
basic java questions and on Spring MVC related questions.
If you can race only 5 horses at a time, given 20 horses, what is the lowest number of races you need to host to determine the top 3 horses
1) How to reverse a string?
implementation of Hash table. what is Polymorphism.
Technical questions on Java (my preferred language) like what is JVM and what does it do.
Given an integer, return all sequences of numbers that sum to it. (Example: 3 -> (1, 2), (2, 1), (1, 1, 1)).
http://blog.csdn.net/yeqiuzs/article/details/52029034
Give me a level by level output of a binary tree. Implement a stack with two queues, etc.
https://stackoverflow.com/questions/688276/implement-stack-using-two-queues
Where does the system interrupt on a computer come from? Or what wakes a sleeping process?
Reverse a linked-list.
Technical Prep – Solid, well thought through answers are required. You need to demonstrate a deep understanding on your core language, the fundamentals and the principles
Example of technical questions asked across interviews include:
· Give an example of a string in palindrome
· Java memory models
· Multi threading
· Java design questions.
· How would you investigate Java performance issues.
· Work situation questions particularly around code reviews.
· SQL questions: normalization: why, is it always good? about primary key and foreign key. What db system I have used? What is a view (is it only for selecting data?) What are indexes and for what reason. https://stackoverflow.com/questions/2955459/what-is-an-index-in-sql
· Java: List interface, what concrete implementation do I know? How ArrayList differs from the LinkedList, what is better for adding a lot of elements, how is ArrayList implemented; About HashMap what happens when I call put, what happens when I call get method. What is equals and hashcode for?
· Explain to me what the following java terms mean: "final", "finally", "finalise"
-
final and finally are standard language features that i could explain well
-
finalise is a very old and unused method on Object in Java that shouldn't really be used. Once he started talking about it being involved with Garbage Collection i remembered that it was a method on Object.
· Tell me the different types of beans in J2EE
-
Had to just clarify what he mean by asking do you mean like Stateful/Stateless and he said yes.
-
So mentioned of Stateless, Statelful, Singleton, Message Beans.
-
He asked me to describe each of them, which i could do apart from Stateful as we don't really use that feature and he agreed that he wasn't too knowledge on its exact implementation either.
· How would you go about debugging a slow running SQL Query.
-
Described using the Explain Plan feature which would give a breakdown of the query plan which can generally point to a problem area.
-
But also described some situations where it has actively given misleading results and that it should always be taken with a pinch of salt.
· Discussion about Java design patterns.
· Database schema.
· normalise a given example.
· various questions about performance, restructuring the example.
· a couple of simple SQL queries.
· Concurrency.
· intricacies of how Java handles the finally block and static synchronised methods.
· technical java question regarding variable scope. Got to know variable scope inside out for this one. Asked to look at a piece of code for this one, and write down what values would be output at certain parts of the code, so involves good knowledge of scope. I found this one tough, because I was getting confused between javascript and Java, both of which I have done rather recently. But to be honest, this is just something which I haven't had problems with generally as I usually define variable names so that there is no confusion. In any case, it 's not rocket science and just needs a lot more hands on practice.
· Technical - function to check whether or not string is palidrome. function to insert an element into linked list. Java memory management. Java execution. Multithreading. Problem of printing nodes in a tree, depth order and then breadth order
· my personal opinions about different programming languages (java, scala, python) and questions arising from my answers
- draw and explain your current system (with lots and lots of follow-ups)
- basic java (around hashcodes, immutability etc)
- java collections and their best suitability
- low and higher level mulithreading in java
- concurrent collections and data structures
- abstract data structures like priority queues and trees in different implementations
- design a given problem in terms of OO (draw a class diagram)
- given a problem what would be your algorithm of solving it
- lots of conceptual questions that don't have the right answers but shows them your thinking, like what is your attitude to testing, TDD, BDD
· write a code to intersect two sets.
· design classes for polynom
· -what are checked/unchecked exceptions and how to use it
· what do I do now in my current role
· I think the I've not answered some questions, e.g. red-black tree algorithm, and sometimes not explained some details until Julien gave some me hints. The questions are:
· write a code to intersect two sets.
· design classes for polynom
· what are checked/unchecked exceptions and how to use it
· Question on how to count the most frequently occurring words in a block of text.
· composition
· difference between linkedlist, set, map
· how to iterate over a list
· how to sort a list
· how to remove duplicates from a list
· -types of exceptions
· differences between abstract class and interface (here he wanted to mention that the abstract class can have a constructor, which I haven't)
· when you have to implement hashCode and equals
· what is an immutable class
1. Java collections, list vs set.
2. Java/JDK synchronization mechanisms - developed into discussion about ReadWrite lock implementation
3. Hashmap vs ConcurrentHashMap
4. Garbage collector
5. Class loader - how JVM loads classes, how to override system class
· The interview focused on Multi-threading generally, including the synchronized keyword, mutual exclusion, thread creation (new/runnable) etc. Some questions on bit manipulation, access modifiers, multi-dimensional arrays, vectors, quite some focus on lists versus sets. There were some puzzles which I don't remember exactly now but can generally be broken down into bin-packing problems I guess.
Here are the questions I remember:
· Difference between List and Set
· Difference between HashSet and LinkedHashSet
· Explain algorithm of adding element to a set
· Thread safety of a HashMap , how we can make it thread safe
· Describe what happens when adding element to the ConcurrentHashMap
Analytical Questions –These are brainteaser type questions which get you thinking in the right way - you need to answer such questions in a clear, logical fashion – being able to think quickly on your feet is central to any role.
· There is a cloud computing company who produce units of X size – how many units are needed to resource for X company
· If you have 15 horses, which all run at different speeds, and a five-lane racecourse, how many races do you need to run to find out which the three fastest horses are?
· L-shapes in 2^n square
-
You have square 2^n x 2^n blocks. One random block in the square is selected. Prove that you can fill the rest of the blocks in the square using just L-shape (: .) blocks. (Not strict prove was required)
· Probability of sum of 2d6
-
You throw two dices. What is the probability that sum of dices will be 11 or 12?
-
3/36
· Is there equal split in array
-
You have array of integers. Write a function that returns true, if you can split the array in such way, that your sum of numbers on the left will equals these on the rights.
-
StepUp()
o You have a robot half-way up an infinite staircase. The robot has a function, Step(), which makes the robot go up or down a step, non-deterministically. 50% of the time the robot goes up one step and the function returns True. 50% of the time the robot goes down one step and the function returns False. Write a function StepUp() which makes the robot go up one step.
The elegant answer:
def StepUp():
if Step():
return
else:
StepUp()
StepUp()
But this elegant answer could use a lot of stack space, which is a waste of memory. Much more efficient to use a single integer to keep track of the position of the robot, which takes a lot less space than using the stack, and is likely to overflow long after the stack runs out of memory.
· Unit tests for database
-
They just wrote some function that connects to database and asked me how would I unit test it.
· 1m coordinates , find closest 1k
-
You have file with 1 million 3-dimenstional coordinates. Select the 1000 that are closest to the point of origin. What would change in approach if instead it would be 1 billion coordinates and you are supposed to select 1 million.
· To decimal from any base
-
Write a function that gets string and an int. String is a number with int base. Function returns number in base 10. What do you need to modify in code for the function to work for bases grater then 10.
· Dictionary
-
You have a dictionary with words. As an input you get a string and in output program should write the words from the string that are in dictionary. E.g. "applepiedog" would return "apple pie dog".
· straight into problem solving. asked the question about calculating area of general shapes. There was a mention of java 'Shape' objects but knowledge of this is not necessary, just general logic of how to calculate area of shapes, given that we have the points that define the shape.
· How many hairdressers are there in the UK?
· The 5 litre, 3litre jug question.
· How many times can you make add up to a £1 using any or all combinations of the current denominations in the currency. They followed by asking how to reverse an array.
· Given a squiggly shape, design an algorithm to work out the area.
· Analytical - Puzzle with 4 servers, all with same capacity, which can host virtual servers with a variable number of CPUs (essentially 4 buckets and items of different sizes). Some servers had a number of servers in the first state. Servers cannot be migrated and we don't care about disk space, access times etc. The problem was built upon step by step.
1. Where do I put this new server?
2. Then another.
3. Then this list of servers.
4. Explain approach.
5. Write algorithm which is blind to list.
6. What if servers came in batches?
7. What if server can have a life of 1, 3 or 5 years?
Personnel Questions – the following are popular:
· What do you do in your current role
· Day to day duties
· Explain current system
· Explain business area
· Explain what you know about our business area
They are, as always, looking for great communication skills and a really good understanding of your role. You need to know the ins and outs – reasons behind the work your doing. They want depth and to be left interested.
Other broad personnel/competency questions asked include:
· What software would you need to set up a hedge fund from scratch? (E.g. static data, pricing data feeds, trading platform, risk management engine, risk simulations, automatic strategy execution...)
· What computer science reading have you done recently? Led on to talk about data structures, algorithms, design patterns.
· Tell me about a time when you had to deal with conflict at work. How did you deal with it?
· Generally talking about my cv and experience
· why did I leave my current job?
· why our company?
· what type of work am I looking for, what role/responsibility?
· Asked me to draw the system I work on. Then how I'd improve it.
· Why finance?
· My understanding of the role (by most of the people I saw).
Other questions asked at this stage include the following, as passed across by a previous candidate:
Also, worth thinking about the following soft questions – they are unlikely to all pop up at this stage but by preparing fully you will be in a great position. You certainly have time to do so:
Why do you want to work for X?
What do you know about X?
Thus far in your career; what have been your key successes?
What will you bring to X?
Not the toughest questions but the delivery is direct.
They might not accept your first answer but ask several more probing questions.
Career history:
You need to know the start and end dates of each position and be able to demonstrate that you 'grew' in each one and your reasons for leaving and joining companies.
The role and company:
Why do you want to work for us?
Why do you feel you are suitable for this job?
Based on your research what do you think is most important to us as an employer?
Why do you think X is right for you?
Motivations and aspirations:
What are your strengths? / What are your weaknesses?
What are your career objectives?
Competency questions:
Give me an example of a time you were a member of a failing team and the steps you took to correct the situation?
How have you dealt with difficult colleagues?
How do you react to change in the work place?
Tell me about a time when you have had to motivate a colleague in the workplace? What strategy did you use to make them more effective?
What are your thoughts to working in a structured environment?
How do you like to be managed?
If I was to tell you I didn’t like you how would you change my mind?
====================================================================
Final keyword has a numerous way to use:
-
A final class cannot be subclassed.
-
A final method cannot be overridden by subclasses
-
A final variable can only be initialized once
Other usage:
-
When an anonymous inner class is defined within the body of a method, all variables declared final in the scope of that method are accessible from within the inner class
Type of indexes:
https://www.postgresql.org/docs/9.2/static/indexes-types.html
What db system I have used? What is a view (is it only for selecting data?) What are indexes and for what reason. https://stackoverflow.com/questions/2955459/what-is-an-index-in-sql
HashMap/HashTable works internally http://www.java67.com/2013/06/how-get-method-of-hashmap-or-hashtable-works-internally.html
Reentrant lock vs synchronized