Mern Stack Developer
60+ Mern Stack Developer Interview Questions and Answers

Asked in Hewlett Packard Enterprise

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

Asked in Josh Technology Group

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
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
Mern Stack Developer Interview Questions and Answers for Freshers

Asked in Myntra

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

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

Asked in BlueStacks

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

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




Asked in LinkedIn

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

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
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 🌟

Asked in Accucia Softwares Private Limited

Q. What are the basic and advanced concepts of the MERN stack?
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

Q. What are the functions of Redux and how does JSON Web Token (JWT) operate?
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 Saksoft

Q. What is the middleware used in redux? write syntax of it. Redux seletors.
Redux middleware is a function that intercepts actions and can modify or dispatch new actions.
Middleware can be used for logging, error handling, and asynchronous actions.
Syntax: const middleware = store => next => action => { //middleware logic }
Redux selectors are functions that extract specific data from the Redux store.
Example: const getUserName = state => state.user.name;
Asked in Vervali Systems

Q. What is the difference between a while loop and a for loop?
While loop is used when the number of iterations is not known beforehand, while for loop is used when the number of iterations is known.
While loop checks a condition before each iteration, for loop has initialization, condition, and increment/decrement expressions.
For loop is more concise and easier to read for iterating over a range of values.
While loop is more flexible and can be used for situations where the number of iterations is not fixed.
Example: while loop - while(i <...read more

Asked in Appgenix Infotech LLP

Q. what is jwt token and difference between jwt token and bearer token
JWT token is a JSON web token used for authentication and authorization. Bearer token is a type of access token that is used to authenticate API requests.
JWT token stands for JSON Web Token and is used for securely transmitting information between parties as a JSON object.
Bearer token is a type of access token that is used to authenticate API requests.
JWT token is self-contained and contains user information and metadata, while bearer token is simply a string that identifies ...read more
Asked in Techpile Technology

Q. What is react-router-dom and whta's is working process?
React-router-dom is a routing library for React applications.
It allows for declarative routing in React applications.
It provides components like BrowserRouter, Route, Switch, and Link.
BrowserRouter is used to wrap the entire application and provide routing functionality.
Route is used to define a route and the component to render when the route is accessed.
Switch is used to render only the first matching route.
Link is used to create links between different routes in the applic...read more
Asked in Brototype

Q. How is multiple inheritance made possible in Java?
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 Techsteck Solutions

Q. What are promises in JavaScript, and why do we need them?
Promises in JavaScript are objects that represent the eventual completion or failure of an asynchronous operation.
Promises have three states: pending, fulfilled, and rejected.
They allow for cleaner asynchronous code, avoiding callback hell.
Example: const myPromise = new Promise((resolve, reject) => { /* async code */ });
You can handle results using .then() for success and .catch() for errors.
Example: myPromise.then(result => console.log(result)).catch(error => console.error(e...read more
Asked in Wingman Partners

Q. react js: architecture of context api and why to use redux.
Context API provides a way to pass data through the component tree without having to pass props down manually. Redux is used for managing global state in complex applications.
Context API allows you to share data across components without having to pass props down manually
Redux is preferred for managing global state in large applications with complex data flow
Context API is simpler to use for smaller applications with less complex state management
Redux provides a centralized s...read more
Asked in Vervali Systems

Q. What is the difference between NoSQL and SQL databases?
NoSQL databases are non-relational databases that do not require a fixed schema, while SQL databases are relational databases that use structured query language.
NoSQL databases are schema-less, allowing for flexibility in data storage
SQL databases use structured query language to interact with data
NoSQL databases are horizontally scalable, making them suitable for big data applications
SQL databases are vertically scalable, typically running on a single server
Examples of NoSQL...read more
Asked in Brototype

Q. Explain the purpose of keywords like 'this' and 'super' in Java.
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 NeoSOFT

Q. What are the differences between useMemo and useCallback in React?
useMemo caches computed values, while useCallback caches functions to prevent unnecessary re-renders in React.
useMemo is used to memoize a computed value, while useCallback is used to memoize a function.
useMemo: const memoizedValue = useMemo(() => computeExpensiveValue(a, b), [a, b]);
useCallback: const memoizedCallback = useCallback(() => { doSomething(a, b); }, [a, b]);
useMemo returns a value, whereas useCallback returns a memoized function.
Both hooks help optimize performan...read more
Asked in Duplex Technology

Q. create product , perform curd opration , make the suggetion in this cart
Create a product cart with CRUD operations and suggestion feature.
Create a database schema for products
Implement CRUD operations for adding, updating, and deleting products
Implement a suggestion feature based on user preferences or past purchases
Asked in Duplex Technology

Q. Describe how to create a multi-select dropdown from scratch, where the selection in one dropdown influences the options available in another.
Create a multi-select dropdown where one selection influences the options of another dropdown.
Use React for building the UI components.
Utilize state management to handle selected values.
Implement a parent component to manage dropdown states.
Example: If 'Fruits' is selected, show options like 'Apple', 'Banana'.
Use libraries like React Select for enhanced dropdown features.
Asked in Duplex Technology

Q. Give me a coding question that resolves multiple promises using Promise.all().
Using Promise.all() to handle multiple asynchronous operations in JavaScript.
Promise.all() takes an array of promises and returns a single promise.
If all promises resolve, it returns an array of results in the same order.
If any promise rejects, it immediately rejects with that reason.
Example: Promise.all([promise1, promise2]).then(results => { console.log(results); });
Useful for parallel execution of asynchronous tasks, like fetching data from multiple APIs.

Asked in Octal IT Solution

Q. How do you handle authentication in a MERN stack application?
Authentication in a MERN stack app typically involves JWT, bcrypt, and secure session management.
Use JSON Web Tokens (JWT) for stateless authentication. Example: Generate a token upon user login.
Hash passwords using bcrypt before storing them in the database. Example: bcrypt.hash(password, saltRounds).
Implement middleware to protect routes. Example: Use a function to verify JWT on protected API endpoints.
Utilize libraries like Passport.js for more complex authentication strat...read more

Asked in iTechnoLabs

Q. What are some logical questions about performance and optimization?
Optimizing performance in MERN stack involves efficient data handling, minimizing requests, and leveraging caching strategies.
Use pagination for large datasets to reduce load times and improve user experience.
Implement server-side caching (e.g., Redis) to store frequently accessed data and reduce database queries.
Optimize MongoDB queries by using indexes to speed up data retrieval.
Minimize the number of API calls by batching requests when possible, reducing network overhead.
U...read more

Asked in Appgenix Infotech LLP

Q. What is the difference between useState and useRef?
useState is used to manage state in functional components, while useRef is used to persist values between renders.
useState is used for managing state in functional components and triggers re-renders when the state changes.
useRef is used to persist values between renders without triggering re-renders.
useState returns a tuple with the current state value and a function to update it, while useRef returns a mutable ref object.
Example: useState can be used to manage a counter in a...read more
Asked in Duplex Technology

Q. Implement a file upload system with multi-select file upload functionality.
Implementing a multiselect file upload system for a MERN stack application.
Use a library like Multer for handling file uploads in Node.js
Create a form in React with multiple file input fields for selecting multiple files
Send the selected files to the server using a POST request
Handle the file uploads on the server side and save them to a designated folder

Asked in NeoSOFT

Q. What are controlled and uncontrolled components?
Controlled components manage form data via React state, while uncontrolled components handle data through the DOM.
Controlled components use React state to manage form inputs, e.g., <input value={this.state.value} onChange={this.handleChange} />.
Uncontrolled components store their own state internally, e.g., <input defaultValue='initial' ref={input => this.input = input} />.
Controlled components provide a single source of truth, making it easier to manage and validate form dat...read more
Asked in Brototype

Q. Explain the process of exception handling.
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

Q. How do you use queries in MongoDB?
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
Interview Questions of Similar Designations
Interview Experiences of Popular Companies





Top Interview Questions for Mern Stack Developer Related Skills



Reviews
Interviews
Salaries
Users

