Front end Developer
700+ Front end Developer Interview Questions and Answers
Q1. Non-Decreasing Array Problem Statement
Given an integer array ARR
of size N
, determine if it can be transformed into a non-decreasing array by modifying at most one element.
An array is defined as non-decreasin...read more
The solution checks if an integer array can become non-decreasing by modifying at most one element.
Iterate through the array and check if there are more than one decreasing pairs of elements.
If there are more than one decreasing pairs, return false.
If there is only one decreasing pair, check if modifying one of the elements can make the array non-decreasing.
If modifying the element at index i-1 or i can make the array non-decreasing, return true.
Otherwise, return false.
Q2. Find Unique Element in Array
You have been provided an integer array/list ARR
of size N
. Here, N
is equivalent to 2M + 1
where each test case has M
numbers appearing twice and one number appearing exactly once....read more
The task is to find the unique number in an array where all other numbers occur twice.
The array size is given by N = 2M + 1, where M is the number of elements occurring twice.
Loop through the array and use a hashmap to count the occurrences of each number.
Return the number with a count of 1, as it is the unique number.
Front end Developer Interview Questions and Answers for Freshers
Q3. Dijkstra's Shortest Path Problem Statement
You are given an undirected graph with V
vertices (numbered from 0 to V-1) and E
edges. Each edge connects two nodes u
and v
and has an associated weight representing ...read more
The question is about finding the shortest path distance from a source node to all vertices in an undirected graph.
The graph is represented by the number of vertices and edges, followed by the edges and their distances.
The task is to find the shortest path distance from the source node (0) to all other nodes.
If a node is disconnected from the source node, print the maximum positive integer value (2147483647).
Implement the function and return the shortest path distances in asc...read more
Q4. Encode N-ary Tree to Binary Tree Problem Statement
You are provided with an N-ary tree constituted of 'N' nodes, where node '1' is the head of the tree. Your task is to encode this N-ary tree into a binary tree...read more
The task is to encode an N-ary tree into a binary tree and then decode the binary tree back into the original N-ary tree.
Encode the N-ary tree by representing each node as a binary tree node with its first child as the left child and subsequent children as the right child.
To decode the binary tree, traverse the binary tree and for each node, create a new N-ary tree node with its left child as the first child and subsequent right children as siblings.
Use a level order traversa...read more
Q5. Sort Array Problem Statement
Given an array consisting of 'N' positive integers where each integer is either 0, 1, or 2, your task is to sort the given array in non-decreasing order.
Input:
Each input starts wi...read more
Q6. Sort Linked List Based on Actual Values
You are given a Singly Linked List of integers that is initially sorted according to the absolute values of its elements. Your task is to sort this Linked List based on t...read more
The task is to sort a singly linked list based on actual values instead of absolute values.
Traverse the linked list and store the values in an array
Sort the array using any sorting algorithm
Create a new linked list using the sorted array
Return the new linked list
Share interview questions and help millions of jobseekers 🌟
Q7. Check If Linked List Is Palindrome
Given a singly linked list of integers, determine if the linked list is a palindrome.
Explanation:
A linked list is considered a palindrome if it reads the same forwards and b...read more
Q8. Path Existence in Directed Graph
Given a directed and unweighted graph characterized by vertices 'V' and edges 'E', determine if a path exists from a specified 'source' vertex to a 'destination' vertex. The edg...read more
The task is to check if there exists a path from a given source vertex to a destination vertex in a directed and unweighted graph.
Read the number of test cases.
For each test case, read the number of vertices and edges.
Read the edges of the graph.
Read the source and destination vertices.
Implement a graph traversal algorithm (e.g., BFS or DFS) to check if a path exists from the source to the destination.
Print 'true' if a path exists, otherwise print 'false'.
Front end Developer Jobs
Q9. Find Magic Index in Sorted Array
Given a sorted array A consisting of N integers, your task is to find the magic index in the given array, where the magic index is defined as an index i such that A[i] = i.
Exam...read more
Q10. How to redirect to login page through React Router if the user has not logged in and trying to go to another page through URL.
Use React Router's Redirect component to redirect to login page if user is not logged in.
Create a PrivateRoute component that checks if user is logged in
If user is not logged in, redirect to login page using Redirect component
Wrap the routes that require authentication with PrivateRoute component
Diameter of a Binary Tree Problem Statement
Given a binary tree, return the length of its diameter. The diameter of a binary tree is defined as the length of the longest path between any two nodes in the tree.
The diameter of a binary tree is the length of the longest path between any two end nodes in the tree.
The diameter of a binary tree can be calculated by finding the maximum of the following three values: 1) the diameter of the left subtree, 2) the diameter of the right subtree, and 3) the longest path that passes through the root node.
To find the diameter of a binary tree, we can use a recursive approach. We calculate the height of the left and right subtrees, and then calcul...read more
Q12. Merge K Sorted Arrays Problem Statement
Given 'K' different arrays that are individually sorted in ascending order, merge all these arrays into a single array that is also sorted in ascending order.
Input
The f...read more
Q13. Palindrome String Validation
Determine if a given string 'S' is a palindrome, considering only alphanumeric characters and ignoring spaces and symbols.
Note:
The string 'S' should be evaluated in a case-insensi...read more
Q14. Remove Duplicates Problem Statement
You are given an array of integers. The task is to remove all duplicate elements and return the array while maintaining the order in which the elements were provided.
Example...read more
Q15. Allocate Books Problem Statement
Given an array of integers arr
, where arr[i]
represents the number of pages in the i-th
book, and an integer m
representing the number of students, allocate all the books in suc...read more
Q16. Rotate Linked List Problem Statement
Given a linked list consisting of 'N' nodes and an integer 'K', your task is to rotate the linked list by 'K' positions in a clockwise direction.
Example:
Input:
Linked List...read more
Q17. Segregate Odd-Even Problem Statement
In a wedding ceremony at NinjaLand, attendees are blindfolded. People from the bride’s side hold odd numbers, while people from the groom’s side hold even numbers. For the g...read more
Q18. Most Frequent Non-Banned Word Problem Statement
Given a paragraph consisting of letters in both lowercase and uppercase, spaces, and punctuation, along with a list of banned words, your task is to find the most...read more
Q19. Reverse Words in a String
Given a string STR
consisting of words separated by spaces, reverse the order of words in STR
.
Note:
A word is defined as a sequence of non-space characters. Attempt to perform the ope...read more
Q20. Swap Two Numbers Problem Statement
Given two integers a
and b
, your task is to swap these numbers and output the swapped values.
Input:
The first line contains a single integer 't', representing the number of t...read more
Q21. 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
Q22. How can you only accept jpg and png files using HTML5.
Use the accept attribute in the input tag to only allow jpg and png files.
Add accept attribute to input tag with 'image/jpeg, image/png' value
This will restrict file selection to only jpg and png files
Q23. Chocolate Distribution Problem
You are given an array/list CHOCOLATES
of size 'N', where each element represents the number of chocolates in a packet. Your task is to distribute these chocolates among 'M' stude...read more
Q24. Matching Prefix Problem Statement
Given an integer N
representing the number of strings in an array Arr
composed of lowercase English alphabets, determine a string S
of length N
such that it can be used to dele...read more
Q25. Alien Dictionary Problem Statement
You are provided with a sorted dictionary (by lexical order) in an alien language. Your task is to determine the character order of the alien language from this dictionary. Th...read more
Q26. LRU Cache Design Question
Design a data structure for a Least Recently Used (LRU) cache that supports the following operations:
1. get(key)
- Return the value of the key if it exists in the cache; otherwise, re...read more
Q27. Jumping Numbers Problem Statement
Given a positive integer N
, your goal is to find all the Jumping Numbers that are smaller than or equal to N
.
A Jumping Number is one where every adjacent digit has an absolute...read more
Q28. Postorder Successor Problem Statement
You are provided with a binary tree consisting of 'N' distinct nodes and an integer 'M'. Your task is to find and return the postorder successor of 'M'.
Note:
The postorder...read more
Q29. String Palindrome Verification
Given a string, your task is to determine if it is a palindrome considering only alphanumeric characters.
Input:
The input is a single string without any leading or trailing space...read more
Q30. Priority CPU Scheduling Problem
Given 'N' processes with their “burst times”, where the “arrival time” for all processes is ‘0’, and the ‘priority’ of each process, your task is to compute the “waiting time” an...read more
Q32. How to center align a div in just one line in css.
Use flexbox to center align a div in just one line in CSS.
Set the parent container's display property to flex.
Use the justify-content property with the value 'center' to horizontally center the div.
Use the align-items property with the value 'center' to vertically center the div.
Q35. Is Javascript single thread or multithread?
Javascript is single-threaded.
Javascript runs on a single thread called the event loop.
This means that it can only execute one task at a time.
However, it can delegate tasks to other threads using web workers.
This allows for parallel processing without blocking the main thread.
Q37. implement a calculator class which does this cal.add(2).sub(3).mul(4).delay(2000).add(4) etc
Implement a calculator class with chaining methods and delay function.
Create a Calculator class with add, sub, mul methods that return the instance of the class.
Implement a delay method that uses setTimeout and returns the instance of the class.
Use a queue to store the operations and execute them in order after the delay.
Return the result of the operations when the equals method is called.
Q41. Remove duplicate elements from an Array
Remove duplicate elements from an Array
Use the Set object to remove duplicate elements
Convert the Set back to an array using the spread operator
If the array contains objects, use a custom comparison function
Q43. What is css media queries and difference between min and max
CSS media queries are used to apply different styles based on device characteristics. Min and max define the range of values.
Media queries allow for responsive design by adapting to different screen sizes and orientations
Min-width and max-width are commonly used to define the range of screen sizes
Min-device-width and max-device-width are used to target specific device characteristics
Other media query features include min-height, max-height, orientation, and resolution
Q44. Why javascript is Dynamic language? Ans: The type of variable is dynamically changed based on the its current value. that is the reason the javascript is treated as as dynamic language.
JavaScript is considered a dynamic language because variables can change types based on their current value.
Variables in JavaScript can hold different types of values at different times
The type of a variable is determined at runtime, not at compile time
Dynamic typing allows for flexibility and ease of use in JavaScript programming
Example: a variable can start as a number and then be reassigned as a string
Q46. Is functional components and class components both are same or not?
Functional components and class components are not the same in React. Functional components are simpler and more lightweight, while class components have additional features like state and lifecycle methods.
Functional components are stateless and are just JavaScript functions that return JSX.
Class components have access to state and lifecycle methods like componentDidMount and componentDidUpdate.
Functional components are easier to read and test, while class components can be ...read more
Q47. how would you optimize the api call on input change(Debouncing)
Debounce the API call on input change to optimize performance.
Implement a debounce function to delay the API call until the user has finished typing.
Set a time interval for the debounce function to wait before making the API call.
Cancel the previous API call if a new input change occurs before the time interval is up.
Use a loading spinner to indicate to the user that the API call is in progress.
Consider using a caching mechanism to store the API response for future use.
Q48. what is jquery? 2.explain architecture of your project.
jQuery is a fast, small, and feature-rich JavaScript library.
jQuery simplifies HTML document traversing, event handling, and animating.
It provides a set of methods for AJAX interactions and DOM manipulation.
jQuery is cross-platform and supports a wide range of browsers.
It has a large community and a vast number of plugins available.
Project architecture depends on the specific project and its requirements.
Q50. How will you develop an application which shows all airports in the country in a map. User needs to login and report any incidents happened in a particular airport
Develop an app to show all airports in a country on a map and allow users to report incidents after logging in.
Use a map API like Google Maps or Mapbox to display all airports in the country
Implement a login system for users to report incidents
Create a form for users to report incidents with fields like airport name, incident type, and description
Store incident reports in a database for future reference and analysis
Interview Questions of Similar Designations
Top Interview Questions for Front end Developer Related Skills
Interview experiences of popular companies
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
Reviews
Interviews
Salaries
Users/Month