EOY: 6+
Tier 1
Recently, I was interviewed by Sprinklr for the position of Lead Product Engineer. A senior person, who identified as an Architect, joined me for the first round. Initially, he asked me some questions related to my current work, which I was able to answer thoroughly. He then asked about load balancers, and I managed to provide all the correct answers, verifying them after the interview.
He presented me with a data structures and algorithms question:
|y
|
|
| P1—-------P2 P3 —------------- 3
| | |
| P4—------P5 P6………………………2
|
| P7 P8 P9………………………1
|
|
|____|_____|_____|____________x
0 1 2 3
Given a data-structure called Point with two integers (positive) carrying X and Y coordinate for the point.
P2, p6,p4, p8
Class Point {
int x;
int y;
Point(int x, int y) {
this.x = x;
this.y = y;
}
}
And an array of 9 such points arranged as depicted (horizontally and vertically aligned as shown),
List<Point> points = new ArrayList<>();
points.add(new Point(1,3)); // P1
points.add(new Point(2,3)); // P2
….
….
points.add(new Point(3,1)); // P9
Find the total number of rectangles that can be drawn by joining the given points
E.g. joining P1, P2, P5, P4 creates a rectangle (highlighted in the figure above).I coded the solution within 20 minutes, covering all edge cases and doing a dry run with possible test cases. The interviewer agreed with the solution, and the call ended on a positive note.
Today, the HR representative told me that I missed some corner cases and have limited experience in software development. Are you kidding me?
Please don’t waste someone’s precious weekend time.