PolicyBazaar.com interview experience Real time questions & tips from candidates to crack your interview

SDE - 1

PolicyBazaar.com
upvote
share-icon
2 rounds | 5 Coding problems

Interview preparation journey

expand-icon
Journey
In the starting, i was not good at the coding parts but after taking course from coding ninjas completely changes my approach i looked in the coding part now.
Application story
The company came to your campus for the selection process. .
Why selected/rejected for the role?
I was rejected because they accept a unique solution from my side which i was not able to provide to them.
Preparation
Duration: 6 months
Topics: Data Structures, Pointers, OOPS, System Design, Algorithms, Dynamic Programming
Tip
Tip

Tip 1 : Prepare any 4-5 ML algorithms properly, especially maths and intuition behind it because it will help to explain to the interviewer in a more efficient manner
Tip 2 : Past project in ML/DS will have added advantage in resume shortlisting
Tip 3 : Coding is also necessary for ML profile( you can't take it lightly)

Application process
Where: Campus
Eligibility: Above 6 CGPA
Resume Tip
Resume tip

Tip 1 : Have at-least 2 good projects explained in short with all important points covered.
Tip 2 : Every skill must be mentioned.
Tip 3 : Focus on skills, projects and experiences more.

Interview rounds

01
Round
Medium
Video Call
Duration45 minutes
Interview date16 Oct 2022
Coding problem2

1. Find Nth Prime

Moderate
15m average time
85% success
0/80
Asked in companies
OlaLivekeeping (An IndiaMART Company)UST Global

You are given a number 'N'. Your task is to find Nth prime number.

A prime number is a number greater than 1 that is not a product of two smaller natural numbers. Prime numbers have only two factors – 1 and the number itself.

Any number greater than 0 is a natural number i.e. natural numbers N = {1, 2, 3, 4,....}

For example:-

If you are asked to find the 7th prime number, it’ll be 17 because the first 7 prime numbers are 2, 3, 5, 7, 11, 13, 17.

Note: 1 is not a prime number.

Follow Up:
Try to solve the problem in O(N log log N) + O(N).
Problem approach

You are given a number 'N'. Your task is to find Nth prime number.
A prime number is a number greater than 1 that is not a product of two smaller natural numbers. Prime numbers have only two factors – 1 and the number itself.
Any number greater than 0 is a natural number i.e. natural numbers N = {1, 2, 3, 4,....}

Try solving now

2. OOPS Question

Difference between Abstract class and Interface.

Problem approach

The differences between Abstract Class and Interface are as follows : 

Abstract Class:
1) Abstract classes have a default constructor and it is called whenever the concrete subclass is instantiated.

2) It contains Abstract methods as well as Non-Abstract methods.

3) The class which extends the Abstract class shouldn’t require the implementation of all the methods, only Abstract
methods need to be implemented in the concrete sub-class.

4) Abstract class contains instance variables.



Interface:
1 )It doesn’t have any constructor and couldn’t be instantiated.

2) The abstract method alone should be declared.

3) Classes that implement the interface should provide the implementation for all the methods.

4) The interface contains only constants.

02
Round
Medium
Video Call
Duration45 minutes
Interview date16 Oct 2022
Coding problem3

1. Java Question

How ConcurrentHashMap works in Java

Problem approach

According to ConcurrentHashMap Oracle docs,

The constructor of ConcurrentHashMap looks like this :

public ConcurrentHashMap (int initialCapacity, float loadFactor, int concurrencyLevel)

So the above line creates a new, empty map with the specified initial capacity, load factor and concurrency level.
where,
Important Parameters to consider from ConcurrentHashMap Constructor :

initialCapacity - the initial capacity. The implementation performs internal sizing to accommodate this many elements.

concurrencyLevel - the estimated number of concurrently updating threads. The implementation performs internal
sizing to try to accommodate this many threads.

In the ConcurrentHashMap Api , you will find the following constants.

static final int DEFAULT_INITIAL_CAPACITY = 16;
static final int DEFAULT_CONCURRENCY_LEVEL = 16;

initial capacity parameter and concurrency level parameters of ConcurrentHashMap constructor (or Object) are set to
16 by default.

1) Thus, instead of a map wide lock, ConcurrentHashMap maintains a list of 16 locks by default ( number of locks equal
to the initial capacity , which is by default 16) each of which is used to lock on a single bucket of the Map.

2) This indicates that 16 threads (number of threads equal to the concurrency level , which is by default 16) can modify the collection at the same time , given ,each thread works on different bucket. 

3) So unlike hashtable, we perform any sort of operation ( update ,delete ,read ,create) without locking on entire map in ConcurrentHashMap.


Retrieval operations (including get) generally do not block, so may overlap with update operations (including put and
remove). Retrievals reflect the results of the most recently completed update operations holding upon their onset.


1) The allowed concurrency among update operations is guided by the optional concurrencyLevel constructor argument
(default 16), which is used as a hint for internal sizing. 

2) The table is internally partitioned to try to permit the indicated number of concurrent updates without contention. 

3) Because placement in hash tables is essentially random, the actual concurrency will vary. 

4) Ideally, you should choose a value to accommodate as many threads as will ever concurrently modify the table. 

5) Using a significantly higher value than you need can waste space and time, and a significantly lower value can lead to thread contention.

2. Java Question

Explain the use of final keyword in variable, method and class.

Problem approach

In Java, the final keyword is used as defining something as constant /final and represents the non-access modifier.

1) final variable :
i) When a variable is declared as final in Java, the value can’t be modified once it has been assigned.

ii) If any value has not been assigned to that variable, then it can be assigned only by the constructor of the class.


2) final method :
i) A method declared as final cannot be overridden by its children's classes.

ii) A constructor cannot be marked as final because whenever a class is inherited, the constructors are not inherited.
Hence, marking it final doesn't make sense. Java throws compilation error saying - modifier final not allowed here


3) final class :
i) No classes can be inherited from the class declared as final. But that final class can extend other classes for its
usage.

3. LRU Cache Implementation

Moderate
25m average time
65% success
0/80
Asked in companies
MicrosoftUberSalesforce

Design and implement a data structure for Least Recently Used (LRU) cache to support the following operations:

1. get(key) - Return the value of the key if the key exists in the cache, otherwise return -1.

2. put(key, value), Insert the value in the cache if the key is not already present or update the value of the given key if the key is already present. When the cache reaches its capacity, it should invalidate the least recently used item before inserting the new item.
You will be given ‘Q’ queries. Each query will belong to one of these two types:
Type 0: for get(key) operation.
Type 1: for put(key, value) operation.
Note :
1. The cache is initialized with a capacity (the maximum number of unique keys it can hold at a time).

2. Access to an item or key is defined as a get or a put operation on the key. The least recently used key is the one with the oldest access time.
Problem approach

Design and implement a data structure for Least Recently Used (LRU) cache to support the following operations:

Try solving now

Here's your problem of the day

Solving this problem will increase your chance to get selected in this company

Skill covered: Programming

How do you remove whitespace from the start of a string?

Choose another skill to practice
Similar interview experiences
SDE - 1
2 rounds | 4 problems
Interviewed by PolicyBazaar.com
1245 views
0 comments
0 upvotes
SDE - 1
2 rounds | 4 problems
Interviewed by PolicyBazaar.com
882 views
0 comments
0 upvotes
SDE - 1
2 rounds | 4 problems
Interviewed by PolicyBazaar.com
920 views
0 comments
0 upvotes
SDE - 1
2 rounds | 4 problems
Interviewed by PolicyBazaar.com
911 views
0 comments
0 upvotes
Companies with similar interview experiences
company logo
SDE - 1
5 rounds | 12 problems
Interviewed by Amazon
115097 views
24 comments
0 upvotes
company logo
SDE - 1
4 rounds | 5 problems
Interviewed by Microsoft
58237 views
5 comments
0 upvotes
company logo
SDE - 1
3 rounds | 7 problems
Interviewed by Amazon
35147 views
7 comments
0 upvotes