Mern Stack Developer

filter-iconFilter interviews by

10+ Mern Stack Developer Interview Questions and Answers for Freshers

Updated 5 Mar 2025

Popular Companies

search-icon

Q1. 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

Q2. 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

Q3. 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.

Frequently asked in,

Q4. 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

Are these interview questions helpful?

Q5. 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.

Frequently asked in,

Q6. 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.

Share interview questions and help millions of jobseekers 🌟

man-with-laptop

Q7. 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'.

Q8. 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 '%'.

Mern Stack Developer Jobs

MERN Stack Developer - React.js/Node.js (4-5 yrs) 4-5 years
Vegavid Technology Pvt. Ltd.
4.9
Lead MERN Stack Developer 5-7 years
Brilworks
4.5
Ahmedabad
MERN Stack Developer 2-8 years
Exponentia Team
4.1
Bangalore / Bengaluru

Q9. 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

Q10. how multiple inheritance is 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 { }

Q11. explain the process of execption 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.

Q12. What are 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

Q13. which tech stack you use 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

Q14. How to 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.

Q15. Create a full stack web app 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

Q16. What is 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

Q17. Make stopwatch in 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

Q18. What is pelindrome

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

Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top Interview Questions for Mern Stack Developer Related Skills

Interview experiences of popular companies

3.6
 • 7.6k Interviews
3.7
 • 4.8k Interviews
3.8
 • 2.9k Interviews
4.0
 • 215 Interviews
3.3
 • 213 Interviews
3.6
 • 34 Interviews
3.0
 • 9 Interviews
5.0
 • 2 Interviews
View all

Calculate your in-hand salary

Confused about how your in-hand salary is calculated? Enter your annual salary (CTC) and get your in-hand salary

Recently Viewed
INTERVIEWS
Gharda Chemicals Limited
No Interviews
JOBS
Codestore Technologies
No Jobs
INTERVIEWS
Precise Biopharma
No Interviews
SALARIES
Codestore Technologies
No Salaries
JOBS
Tower Research Capital LLC
No Jobs
INTERVIEWS
Gharda Chemicals Limited
No Interviews
INTERVIEWS
Gharda Chemicals Limited
No Interviews
INTERVIEWS
Gharda Chemicals Limited
No Interviews
SALARIES
Codestore Technologies
INTERVIEWS
vSplash Techlabs
No Interviews
Mern Stack Developer Interview Questions
Share an Interview
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

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

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter