Mern Stack Developer

20+ Mern Stack Developer Interview Questions and Answers for Freshers

Updated 9 Jul 2025
search-icon

Q. Middle of a Linked List

You are given the head node of a singly linked list. Your task is to return a pointer pointing to the middle of the linked list.

If there is an odd number of elements, return the middle ...read more

Ans.

Given the head node of a singly linked list, return a pointer to the middle node. If there are an odd number of elements, return the middle element. If there are even elements, return the one farther from the head node.

  • Traverse the linked list using two pointers, one moving one node at a time and the other moving two nodes at a time.

  • When the fast pointer reaches the end of the list, the slow pointer will be at the middle node.

  • If the number of elements is even, return the seco...read more

6d ago

Q. Huffman Coding Challenge

Given an array ARR of integers containing 'N' elements where each element denotes the frequency of a character in a message composed of 'N' alphabets of an alien language, your task is ...read more

Ans.

The task is to find the Huffman codes for each alphabet in an encoded message based on their frequencies.

  • The Huffman code is a binary string that uniquely represents each character in the message.

  • The total number of bits used to represent the message should be minimized.

  • If there are multiple valid Huffman codes, any of them can be printed.

  • The input consists of multiple test cases, each with an array of frequencies.

  • Implement the function to find the Huffman codes and return 1 ...read more

Asked in Myntra

4d ago

Q. Path Reversals Problem Statement

You are provided with a directed graph and two nodes, 'S' and 'D'. Your objective is to determine the minimum number of edges that need to be reversed to establish a path from n...read more

Ans.

The task is to find the minimum number of edges that need to be reversed in a directed graph to find the path from a start node to an end node.

  • The problem can be solved using graph traversal algorithms like Breadth First Search (BFS) or Depth First Search (DFS).

  • Start by creating an adjacency list representation of the directed graph.

  • Perform a BFS or DFS from the start node to the end node, keeping track of the number of edges reversed.

  • Return the minimum number of edges revers...read more

Asked in Samsung

2d ago

Q. Triplets with Given Sum Problem

Given an array or list ARR consisting of N integers, your task is to identify all distinct triplets within the array that sum up to a specified number K.

Explanation:

A triplet i...read more

Ans.

The task is to find all distinct triplets in an array that add up to a given sum.

  • Iterate through the array and fix the first element of the triplet.

  • Use two pointers approach to find the other two elements that sum up to the remaining target.

  • Handle duplicates by skipping duplicate elements while iterating.

  • Return the list of valid triplets.

Are these interview questions helpful?

Asked in BlueStacks

2d ago

Q. Move Zeroes to End

Given an unsorted array of integers, rearrange the elements such that all the zeroes are moved to the end, while maintaining the order of non-zero elements.

Input:

The first line contains an ...read more
Ans.

Rearrange an unsorted array by moving all zeroes to the end while maintaining the order of non-zero elements.

  • Iterate through the array and keep track of the count of non-zero elements encountered.

  • While iterating, if the current element is non-zero, swap it with the element at the count index.

  • After iterating, fill the remaining elements with zeroes.

Asked in Nagarro

3d ago

Q. Trapping Rain Water Problem Statement

You are given a long type array/list ARR of size N, representing an elevation map. The value ARR[i] denotes the elevation of the ith bar. Your task is to determine the tota...read more

Ans.

The question asks to find the total amount of rainwater that can be trapped in the given elevation map.

  • Iterate through the array and find the maximum height on the left and right of each bar.

  • Calculate the amount of water that can be trapped at each bar by subtracting its height from the minimum of the maximum heights on the left and right.

  • Sum up the amount of water trapped at each bar to get the total amount of rainwater trapped.

Mern Stack Developer Jobs

Capgemini Technology Services India Limited logo
MERN Stack Developer 2-4 years
Capgemini Technology Services India Limited
3.7
Noida
Infosys Limited logo
MERN Stack Developer 7-9 years
Infosys Limited
3.6
Bangalore / Bengaluru
Infosys Limited logo
MERN Stack Developer 3-5 years
Infosys Limited
3.6
Bangalore / Bengaluru

Asked in LinkedIn

6d ago

Q. Decode Ways Problem Statement

Given a string strNum that represents a number, the task is to determine the number of ways to decode it using the following encoding: 'A' - 1, 'B' - 2, ..., 'Z' - 26.

Input:

The f...read more
Ans.

The task is to determine the number of ways to decode a given number string using a specific encoding.

  • Iterate through the string and use dynamic programming to calculate the number of ways to decode at each position.

  • Consider different cases such as single digit decoding, double digit decoding, and invalid decoding.

  • Use modulo 10^9+7 to handle potentially large numbers of decode ways.

  • Example: For '226', there are 3 possible decodings: 'BZ', 'BBF', 'VF'.

Asked in Tredence

3d ago

Q. Find First Repeated Character in a String

Given a string 'STR' composed of lowercase English letters, identify the character that repeats first in terms of its initial occurrence.

Example:

Input:
STR = "abccba"...read more
Ans.

Find the first repeated character in a given string composed of lowercase English letters.

  • Iterate through the string and keep track of characters seen so far in a set.

  • If a character is already in the set, return it as the first repeated character.

  • If no repeated character is found, return '%'.

Share interview questions and help millions of jobseekers 🌟

man-with-laptop

Q. What are the basic and advanced concepts of the MERN stack?

Ans.

The MERN stack consists of MongoDB, Express.js, React.js, and Node.js, enabling full-stack JavaScript development.

  • MongoDB: A NoSQL database that stores data in JSON-like documents, allowing for flexible data structures.

  • Express.js: A web application framework for Node.js that simplifies server-side development and routing.

  • React.js: A front-end library for building user interfaces, allowing for component-based architecture and state management.

  • Node.js: A JavaScript runtime that...read more

Asked in GraffersID

5d ago

Q. What are the functions of Redux and how does JSON Web Token (JWT) operate?

Ans.

Redux manages application state, while JWT securely transmits information between parties.

  • Redux is a state management library for JavaScript applications, particularly with React.

  • It uses a single store to hold the entire state of the application, making state predictable.

  • Actions are dispatched to modify the state, which are processed by reducers.

  • Example: An action could be 'ADD_TODO', and the reducer updates the state with a new todo item.

  • JSON Web Token (JWT) is a compact, UR...read more

Asked in Brototype

6d ago

Q. How is multiple inheritance made possible in Java?

Ans.

Java does not support multiple inheritance, but it can be achieved through interfaces.

  • Java does not allow multiple inheritance of classes due to the diamond problem.

  • However, multiple inheritance can be achieved through interfaces.

  • A class can implement multiple interfaces, which can have their own default implementations.

  • Example: class A implements Interface1, Interface2 { }

Asked in Brototype

2d ago

Q. Explain the purpose of keywords like 'this' and 'super' in Java.

Ans.

Java keywords like 'this' and 'super' are essential for object-oriented programming, enabling access to class members and inheritance.

  • 'this' refers to the current object instance, allowing access to instance variables and methods.

  • Example: 'this.variableName' differentiates between instance variables and parameters.

  • 'super' is used to access superclass methods and constructors, facilitating inheritance.

  • Example: 'super()' calls the parent class constructor, while 'super.methodNa...read more

Asked in Brototype

2d ago

Q. Explain the process of exception handling.

Ans.

Exception handling is the process of handling errors and unexpected events in a program.

  • Exceptions are thrown when an error occurs in the program.

  • The try-catch block is used to handle exceptions.

  • The catch block catches the exception and handles it appropriately.

  • Finally block is used to execute code regardless of whether an exception was thrown or not.

  • Exception handling helps in making the program more robust and prevents it from crashing.

Asked in GraffersID

2d ago

Q. How do you use queries in MongoDB?

Ans.

MongoDB queries allow for flexible data retrieval and manipulation using a rich query language tailored for document databases.

  • Find Documents: Use `db.collection.find({})` to retrieve documents. Example: `db.users.find({ age: { $gt: 18 } })` fetches users older than 18.

  • Insert Documents: Use `db.collection.insertOne({})` or `db.collection.insertMany([{}])` to add new documents. Example: `db.products.insertOne({ name: 'Laptop', price: 999 })`.

  • Update Documents: Use `db.collectio...read more

6d ago

Q. What are the different kinds of hooks?

Ans.

Hooks are functions that let you use state and other React features without writing a class.

  • useState() - for managing state in functional components

  • useEffect() - for side effects in functional components

  • useContext() - for accessing context in functional components

  • useReducer() - alternative to useState() for more complex state logic

3d ago

Q. Which tech stack have you used previously?

Ans.

I have previously used the MERN stack which includes MongoDB, Express.js, React, and Node.js.

  • MongoDB for database management

  • Express.js for building the backend server

  • React for building the frontend user interface

  • Node.js for server-side scripting

4d ago

Q. How do you hash a password?

Ans.

To hash a password, use a secure hashing algorithm like bcrypt.

  • Use a secure hashing algorithm like bcrypt to hash the password.

  • Generate a salt to add to the password before hashing.

  • Hash the password using the bcrypt library function.

  • Store the hashed password and the salt securely in the database.

5d ago

Q. Create a full stack web application using React.

Ans.

A full stack web app using React

  • Set up a Node.js server with Express

  • Create a database using MongoDB

  • Build the frontend using React components

  • Connect frontend to backend using API calls

  • Implement user authentication and authorization

  • Deploy the app on a hosting platform like Heroku

Asked in FargoWiz

4d ago

Q. What are state and props?

Ans.

State and props are two important concepts in React for managing data and passing data between components.

  • State is a built-in feature in React components that allows components to have their own internal data that can change over time.

  • Props (short for properties) are used to pass data from a parent component to a child component.

  • State is mutable and can be changed within the component, while props are read-only and cannot be changed within the component.

  • State is typically use...read more

3d ago

Q. Implement a stopwatch using React.

Ans.

Create a stopwatch using React

  • Create a state variable to hold the time

  • Use setInterval to update the time every second

  • Render the time in the component

  • Add buttons to start, stop, and reset the stopwatch

6d ago

Q. What is a palindrome?

Ans.

A palindrome is a word, phrase, number, or other sequence of characters that reads the same forward and backward.

  • Palindrome is a sequence of characters that reads the same backward as forward

  • Examples: 'racecar', 'level', 'deified', 'madam', 'civic'

  • Palindrome can also be a phrase or a number, such as 'A man, a plan, a canal, Panama!' or '121'

  • Palindrome is commonly used in programming to check if a string is the same when reversed

Q. What motivates you?

Ans.

I am motivated by challenges, continuous learning, and the impact of my work on users and the community.

  • I thrive on solving complex problems, like optimizing a slow API response time to enhance user experience.

  • Continuous learning drives me; I regularly explore new technologies, such as GraphQL, to improve my skill set.

  • I find motivation in user feedback; for instance, receiving positive comments on a feature I developed inspires me to innovate further.

  • Collaboration with my tea...read more

Asked in MagicBricks

1d ago

Q. What are your hobbies?

Ans.

I enjoy coding, playing video games, and exploring new technologies, which helps me stay creative and sharp in my development skills.

  • Coding personal projects, like building a weather app using React and Node.js.

  • Playing video games, especially strategy games like StarCraft, which enhance my problem-solving skills.

  • Exploring new technologies, such as learning about GraphQL and its integration with MongoDB.

Interview Experiences of Popular Companies

Capgemini Logo
3.7
 • 5.1k Interviews
LTIMindtree Logo
3.7
 • 3k Interviews
NeoSOFT Logo
3.6
 • 280 Interviews
IGT Solutions Logo
3.3
 • 233 Interviews
Myntra Logo
3.9
 • 229 Interviews
View all

Top Interview Questions for Mern Stack Developer Related Skills

interview tips and stories logo
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories
Mern Stack Developer Interview Questions
Share an Interview
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits