Welcome to my post, I will list some of the interview questions that I encountered in the interview process I been through. Hope it will help you to crack your interview process.
Remember, interview process is not about the solution of a problem its all about how you approach the given problem.
Round 1 (Technical Screening):
This round is basically the screening round of around 30-45 mins & its a live coding session in which interviewer can ask questions about your approach for a given problem
Question : Given a tuple [('John', 95), ('Danny', 98), ('Aaron', 90), ('Leo', 94)]
sort this by the name of the person.
One solution can be to use bubble sort on 0th index of each tuple & swapping the whole tuple at a time.
Another solution can be to use sorted inbuilt method to sort the list of tuples like this -
people = [('John', 95), ('Danny', 98), ('Aaron', 90), ('Leo', 94)]
# argument to lambda function is the whole list of tuple & it will
# set the key to sort on the basis of the 0th index of each tuple
people = sorted(people, key=lambda x: x[0])
print(people)
Output:
[('Aaron', 90), ('Danny', 98), ('John', 95), ('Leo', 94)]
Question 2: Given a Roman Numeral, convert it to its integer value. for example III -> 3, IV -> 4 and so on.
For complete problem statement refer to this link
There are multiple ways to solve this problem, please give it 10-15 mins & try to breakdown the problem. You can find the solution either at leetcode or at geeksforgeeks portal.
Round 2 (Technical Round):
In this round, interviewer can ask the Data structures & algorithms along with the technical questions related to the language you are about to work on in that company. So mine was a Python so I can provide you the questions related to python only.
Question : What are Enumerations ?
Enumerations are created using class, they just have names and values associated with them. In python, you can implement Enumerations using enum module. Enums are iterable, supports hashing & can be accessed either by name or value.
Example :
import enum
class Programming(enum.Enum):
python = 1
java = 2
Question : Can be the complexity of fetching an element from a dictionary different than O(1)? In what cases? Is O(1) the best case, worst case, or average-case complexity?
Yes, the complexity of fetching an element from a dictionary can be different than O(1). In worst case scenario, the complexity of getting an element from dictionary is O(N). O(1) is the average case complexity
Question : What are generators? Give a use case?
A generator-function is defined like a normal function, but whenever it needs to generate a value, it does so with the yield keyword rather than return. If the body of a def contains yield, the function automatically becomes a generator function, example :
# A generator function that yields 1 for first time,
# 2 second time and 3 third time
def simpleGeneratorFun():
yield 1
yield 2
yield 3
# Driver code to check above generator function
for value in simpleGeneratorFun():
print(value)
Generators are often used for streaming large amount of data which is obviously memory efficient.
Question : What are transactions? If there is a system failure inside the transaction then what will happen?
A transaction is an atomic set of database queries. A transaction in a database system must maintain Atomicity, Consistency, Isolation, and Durability − commonly known as ACID properties − in order to ensure accuracy, completeness, and data integrity.
The checkpoint is used to declare a point before which the DBMS was in the consistent state, and all transactions were committed.
If there is a system failure inside the transaction then the transaction will rollback to its previous checkpoint.
Question : Difference b/w tuple and list, what do you mean by immutable ?
The key difference between a tuple and list is that while the tuples are immutable objects the lists are mutable. This means the tuple cannot be changed while the lists can be modified.
Question : What is the n+1 problem and how can you solve it ?
The N+1 query problem happens when your code executes N additional query statements to fetch the same data that could have been retrieved when executing the primary query.
Refer to this link for in depth details.
Question : When should we use MongoDB and when relational database?
It always depends on the use case but generally it's better to use relational databases when the requirements are clear and there are no dynamic attributes involved in the structure. If there some dynamic attributes involved that you are not aware of at the time then its better to use MongoDB or non-relational databases.
For example, if your designing a database to store the product and their details then maintaining a relational database for the same is much more complex then maintaining a non relational database for the same.
Question: What is a gunicorn? How can we scale an application using a gunicorn?
Gunicorn is a WSGI server that takes care of everything which happens in-between the web server and your web application. It also takes care of running multiple instances of your web application, making sure they are healthy and restart them as needed, distributing incoming requests across those instances and communicate with the web server.
Gunicorn allows us to run multiple worker processes of a single app. It’s really simple, and we can easily scale up or down our number of workers.
Question : How do will you define abstract classes in Python program?
Answer : The ABC class is inherited from the abc module to define the abstract class.
from abc import ABC
class AbstractLanguage(ABC):
@abstractmethod
def created_by(self):
pass
To implement this class just inherit it and implement the abstract methods.
class Python(AbstractLanguage):
def created_by(self):
print("Guido van Rossum")
Try to design more complex patterns using abstract classes. It will improve your code structure & will make you a better developer than others.
That's it. Good luck for your next interview, Hope it helps you to gain some knowledge, if you like this article or if you want to add any question/topic here please let me know in the comments. Thanks.
Top comments (0)