Member Technical Staff
100+ Member Technical Staff Interview Questions and Answers
Popular Companies
Q1. Next Smallest Palindrome Problem Statement
Find the next smallest palindrome strictly greater than a given number 'N' represented as a string 'S'.
Explanation:
You are given a number in string format, and your ...read more
Find the next smallest palindrome greater than a given number represented as a string.
Iterate from the middle of the number and mirror the left side to the right side to create a palindrome
If the resulting palindrome is greater than the input number, return it
Handle cases where the number has all 9s and requires a carry over to the left side
Q2. Buy and Sell Stock Problem Statement
Imagine you are Harshad Mehta's friend, and you have been given the stock prices of a particular company for the next 'N' days. You can perform up to two buy-and-sell transa...read more
The task is to determine the maximum profit that can be achieved by performing up to two buy-and-sell transactions on a given set of stock prices.
Iterate through the array of stock prices to find the maximum profit that can be achieved by buying and selling stocks at different points.
Keep track of the maximum profit that can be achieved by considering all possible combinations of buy and sell transactions.
Ensure that you sell the stock before buying again to adhere to the con...read more
Member Technical Staff Interview Questions and Answers for Freshers
Q3. Check Permutation Problem Statement
Given two strings 'STR1' and 'STR2', determine if they are anagrams of each other.
Explanation:
Two strings are considered to be anagrams if they contain the same characters,...read more
Check if two strings are anagrams of each other by comparing their characters.
Create a character frequency map for both strings and compare them.
Sort both strings and compare if they are equal.
Use a hash set to store characters from one string and remove them while iterating through the other string.
Check if the character counts of both strings are equal.
Example: For input 'listen' and 'silent', the output should be true.
Q4. Optimal Strategy for a Coin Game
You are playing a coin game with your friend Ninjax. There are N
coins placed in a straight line.
Here are the rules of the game:
1. Each coin has a value associated with it.
2....read more
The problem involves finding the optimal strategy to accumulate the maximum amount in a coin game with specific rules.
Start by considering the base cases where there are only 1 or 2 coins.
Use dynamic programming to keep track of the maximum amount that can be won at each step.
Consider the different scenarios when choosing a coin from either end of the line.
Keep track of the total winnings for both players and choose the optimal strategy to maximize your winnings.
Implement a r...read more
Q5. Longest Happy String Problem Statement
Given three non-negative integers X
, Y
, and Z
, determine the longest happy string. A happy string is defined as a string that contains only the letters 'a', 'b', and 'c' w...read more
The longest happy string problem involves constructing a string with 'a', 'b', and 'c' without having any three consecutive letters being the same.
Determine the maximum number of times 'a', 'b', and 'c' can appear in the string based on the given input values.
Construct the longest happy string by alternating between 'a', 'b', and 'c' while respecting the constraints.
Return '1' if a correct happy string can be formed, otherwise return '0'.
Q6. Spiral Matrix Problem Statement
You are given a N x M
matrix of integers. Your task is to return the spiral path of the matrix elements.
Input
The first line contains an integer 'T' which denotes the number of ...read more
The task is to return the spiral path of elements in a given matrix.
Iterate through the matrix in a spiral path by keeping track of boundaries.
Print elements in the order of top row, right column, bottom row, and left column.
Continue the spiral path until all elements are printed.
Share interview questions and help millions of jobseekers 🌟
Q7. Cycle Detection in a Singly Linked List
Determine if a given singly linked list of integers forms a cycle or not.
A cycle in a linked list occurs when a node's next
points back to a previous node in the list. T...read more
Detect if a singly linked list forms a cycle by checking if a node's next pointer points back to a previous node.
Traverse the linked list using two pointers, one moving one step at a time and the other moving two steps at a time.
If the two pointers meet at any point, there is a cycle in the linked list.
Use Floyd's Cycle Detection Algorithm for efficient detection of cycles in linked lists.
Q8. Maximum Sum Problem Statement
You are given an array ARR
of N integers. Your task is to perform operations on this array until it becomes empty, and maximize the sum of selected elements. In each operation, sel...read more
Given an array, select elements to maximize sum by removing adjacent elements.
Iterate through the array and keep track of the count of each element.
Select the element with the highest count first, then remove adjacent elements.
Repeat the process until the array is empty and sum the selected elements.
Member Technical Staff Jobs
Use a stack data structure for implementing undo and redo operations.
Stack data structure is ideal for implementing undo and redo operations as it follows Last In First Out (LIFO) principle.
Push the state of the system onto the stack when an action is performed, allowing for easy undo by popping the top element.
Redo operation can be implemented by keeping a separate stack for redo actions.
Example: In a text editor, each change in text can be pushed onto the stack for undo and...read more
Q10. Detect and Remove Loop in Linked List
For a given singly linked list, identify if a loop exists and remove it, adjusting the linked list in place. Return the modified linked list.
Expected Complexity:
Aim for a...read more
Detect and remove loop in a singly linked list in place with O(n) time complexity and O(1) space complexity.
Use Floyd's Cycle Detection Algorithm to identify the loop in the linked list.
Once the loop is detected, use two pointers to find the start of the loop.
Adjust the pointers to remove the loop and return the modified linked list.
Q11. Regular Expression Match Problem Statement
Given a string str
and a string pat
, where str
may contain wildcard characters '?' and '*'.
If a character is '?', it can be replaced with any single character. If a c...read more
The task is to determine if it is possible to transform a string to match another string using wildcard characters '?' and '*'.
Iterate through both strings simultaneously, handling wildcard characters '?' and '*' accordingly.
Use dynamic programming to keep track of matching subproblems.
Return true if at the end both strings match, false otherwise.
Q12. Count Ways to Reach the N-th Stair Problem Statement
You are provided with a number of stairs, and initially, you are located at the 0th stair. You need to reach the Nth stair, and you can climb one or two step...read more
The problem involves counting the number of distinct ways to climb N stairs by taking 1 or 2 steps at a time.
Use dynamic programming to solve the problem efficiently.
The number of ways to reach the Nth stair is the sum of the number of ways to reach the (N-1)th stair and the (N-2)th stair.
Handle base cases for N=0 and N=1 separately.
Apply modulo operation to avoid overflow while calculating the result.
Consider using memoization to optimize the solution by storing intermediate...read more
Q13. Good Arrays Problem Statement
You are given an array 'A' of length 'N'. You must choose an element from any index in this array and delete it. After deleting the element, you will obtain a new array of length '...read more
Given an array, find the number of 'good' arrays that can be formed by deleting one element.
Iterate through each element in the array and check if deleting it results in a 'good' array
Keep track of the sum of elements at odd and even indices to determine if the array is 'good'
Return the count of 'good' arrays
Q14. Minimum Swaps to Sort Array Problem Statement
Given an array arr
of size N
, determine the minimum number of swaps required to sort the array in ascending order. The array consists of distinct elements only.
Exa...read more
The minimum number of swaps required to sort an array of distinct elements in ascending order.
Use a hashmap to store the index of each element in the array.
Iterate through the array and swap elements to their correct positions.
Count the number of swaps needed to sort the array.
Q15. Predecessor and Successor in Binary Search Tree (BST)
Given a binary search tree (BST) with 'N' nodes, find the predecessor and successor of a given 'KEY' node in the BST.
Explanation:
The predecessor of a node...read more
Find predecessor and successor of a given node in a binary search tree (BST).
Predecessor is the node visited just before the given node in an inorder traversal.
Successor is the node visited immediately after the given node in an inorder traversal.
Return -1 if predecessor or successor does not exist.
Implement inorder traversal to find predecessor and successor.
Q16. Move Zeroes to End
Given an unsorted array of integers, adjust the array such that all zeroes are moved to the end while preserving the order of non-zero elements.
Input:
The input provided consists of multiple...read more
Move all zeroes in an unsorted array to the end while preserving the order of non-zero elements.
Iterate through the array and maintain two pointers - one for the current position and one for the position to swap with.
If the current element is non-zero, swap it with the element at the swap pointer and increment the swap pointer.
After iterating through the array, fill the remaining positions with zeroes.
Example: Input: [0, 1, -2, 3, 4, 0, 5, -27, 9, 0], Output: [1, -2, 3, 4, 5,...read more
Q17. Suppose there is an unsorted array. What will be the maximum window size, such that when u sort that window size, the whole array becomes sorted. Eg, 1 2 6 5 4 3 7 . Ans: 4 (6 5 4 3)
Find the maximum window size to sort an unsorted array.
Identify the longest decreasing subarray from the beginning and longest increasing subarray from the end
Find the minimum and maximum element in the identified subarrays
Expand the identified subarrays until all elements in the array are covered
The length of the expanded subarray is the maximum window size
Q18. Longest Common Prime Subsequence Problem Statement
Imagine Ninja is tackling a puzzle during his long summer vacation. He has two arrays of integers, each with lengths 'N' and 'M'. Ninja's task is to determine ...read more
Find the length of the longest common prime subsequence between two arrays of integers.
Iterate through both arrays to find prime numbers
Use a set to keep track of common prime numbers
Return the size of the set as the length of the longest common prime subsequence
Q19. Stack using Two Queues Problem Statement
Develop a Stack Data Structure to store integer values using two Queues internally.
Your stack implementation should provide these public functions:
Explanation:
1. Cons...read more
Implement a stack using two queues to store integer values with specified functions.
Create a stack class with two queue data members.
Implement push(data), pop(), top(), size(), and isEmpty() functions.
Use one queue for pushing elements and another for temporary storage during operations.
Ensure proper handling of edge cases such as empty stack.
Example: If input is Q = 5, 1 42, 2, 3, 1 17, the output should be 42, -1, 17.
Q20. Convert Array to Min Heap Task
Given an array 'ARR' of integers with 'N' elements, you need to convert it into a min-binary heap.
A min-binary heap is a complete binary tree where each internal node's value is ...read more
Convert the given array into a min-binary heap by modifying the array elements.
Iterate through the array and heapify each node starting from the last non-leaf node to the root node.
For each node, compare it with its children and swap if necessary to satisfy the min-heap property.
Continue this process until the entire array is converted into a min-heap.
Q21. Tower of Hanoi Problem Statement
You have three rods numbered from 1 to 3, and 'N' disks initially stacked on the first rod in increasing order of their sizes (largest disk at the bottom). Your task is to move ...read more
Tower of Hanoi problem where 'N' disks need to be moved to another rod following specific rules in less than 2^N moves.
Implement a recursive function to move disks from one rod to another following the rules.
Use the concept of recursion and backtracking to solve the Tower of Hanoi problem efficiently.
Maintain a count of moves and track the movement of disks in a 2-D array/list.
Ensure that larger disks are not placed on top of smaller disks while moving.
Return the 2-D array/li...read more
Q22. What is a class in js means? And explain its use case
A class in JavaScript is a blueprint for creating objects with similar properties and methods.
Classes are used to create multiple objects with the same structure and behavior.
They provide a way to organize and encapsulate related data and functions.
Classes can have properties (variables) and methods (functions) that define their behavior.
Instances of a class can be created using the 'new' keyword.
Classes can also have constructors, which are special methods called when an obj...read more
Q23. Implementing a Priority Queue Using Heap
Ninja has been tasked with implementing a priority queue using a heap data structure. However, he is currently busy preparing for a tournament and has requested your ass...read more
Implement a priority queue using a heap data structure by completing the provided functions.
Implement push() function to insert elements into the queue.
Implement pop() function to remove the largest element from the queue.
Implement getMaxElement() function to return the largest element.
Implement isEmpty() function to check if the queue is empty.
Q24. Merge Sort Problem Statement
Given a sequence of numbers ARR
, your task is to return a sorted sequence of ARR
in non-descending order using the merge sort algorithm.
Explanation:
The Merge Sort Algorithm is a D...read more
Implement the merge sort algorithm to sort a given sequence of numbers in non-descending order.
Divide the input array into two halves recursively until each subarray has only one element.
Merge the sorted subarrays back together in non-descending order.
Time complexity of merge sort is O(n log n) and space complexity is O(n).
Yes, I can design the bank architecture using basic OOP concepts in any programming language.
Create classes for entities like Bank, Account, Customer, Transaction, etc.
Use inheritance to model relationships between entities (e.g. SavingsAccount and CheckingAccount inheriting from Account).
Implement encapsulation to hide internal details of classes and provide public interfaces for interaction.
Utilize polymorphism to allow different classes to be treated as instances of a comm...read more
Q26. What is merge sort and Quick sort. Adv and Disadv of each and which one would u use to sort huge list and Y
Merge sort and Quick sort are sorting algorithms used to sort arrays of data.
Merge sort is a divide and conquer algorithm that divides the input array into two halves, sorts each half recursively, and then merges the sorted halves.
Quick sort is also a divide and conquer algorithm that selects a pivot element and partitions the array around the pivot, sorting the two resulting sub-arrays recursively.
Merge sort has a time complexity of O(n log n) and is stable, but requires add...read more
Q27. Puzzle: There is a grid of soldier standing. Soldier ‘A’ is chosen: The tallest men from every column and the shortest among them. Soldier ‘B’ is chosen: The shortest men from every row and the tallest among th...
read moreComparison of heights of two soldiers chosen based on different criteria from a grid of soldiers.
Soldier A is chosen based on tallest men from every column and shortest among them.
Soldier B is chosen based on shortest men from every row and tallest among them.
The height of Soldier A and Soldier B cannot be determined without additional information about the grid of soldiers.
Q28. How to find a loop in a Linked List and how to remove it
To find and remove a loop in a Linked List, we can use Floyd's Cycle Detection Algorithm.
Use two pointers, slow and fast, to detect if there is a loop in the Linked List
If the two pointers meet at some point, there is a loop
To remove the loop, set one of the pointers to the head of the Linked List and move both pointers one step at a time until they meet again
The meeting point is the start of the loop, set the next pointer of this node to NULL to remove the loop
Q29. Given a social networking graph find the density of a person. Density is how many friends he had interaction with him and the person by the total number of friends for that person
Density of a person in a social networking graph is the ratio of friends who interacted with the person to the total number of friends.
Calculate the number of friends who interacted with the person.
Calculate the total number of friends for that person.
Divide the number of interacting friends by the total number of friends to get the density.
Density = (Number of interacting friends) / (Total number of friends)
Q30. How to find longest last occurring word in a sentence with multiple whitespace
Finding the longest last occurring word in a sentence with multiple whitespace.
Split the sentence into words using whitespace as delimiter
Reverse the list of words
Iterate through the list and find the first occurrence of each word
Calculate the length of each last occurring word
Return the longest last occurring word
Q31. What’s priority queue. How will u make stack and queue with priority queue
Priority queue is a data structure that stores elements with priority levels and retrieves them in order of priority.
Priority queue is implemented using a heap data structure.
Stack can be implemented using a priority queue by assigning higher priority to the most recently added element.
Queue can be implemented using a priority queue by assigning higher priority to the oldest element.
Q32. Whenever a row in table is modified, how can you make changes to reflect in another related table?
Use triggers to update related table on row modification.
Create a trigger on the main table to update the related table
Use the UPDATE statement in the trigger to modify the related table
Ensure that the trigger is efficient and does not cause performance issues
Test the trigger thoroughly to ensure that it works as expected
Q33. You are given a list of n numbers. How would you find the median in this stream. You are given an array. Give an algorithm to randomly shuffle it.
Algorithm to find median in a stream of n numbers
Sort the list and find the middle element for odd n
For even n, find the average of middle two elements
Use a min-heap and max-heap to maintain the smaller and larger half of the stream respectively
Insert new elements into the appropriate heap and balance the heaps to ensure median is always at the top
std::list from the C++ Standard Template Library (STL) allows insertion and removal of data from anywhere.
std::list is a doubly linked list implementation in STL
Elements can be inserted or removed from anywhere in the list efficiently
Example: std::list<int> myList; myList.insert(myList.begin(), 5); myList.erase(myList.begin());
Q35. Solve and code the problem of a ball falling from staircase. Each jump can be of 1 step or 2. Find the number of combination of reaching step N
Code to find number of combinations of reaching step N by ball falling from staircase with 1 or 2 steps per jump.
Use dynamic programming to solve the problem
Create an array to store the number of ways to reach each step
Initialize the array with base cases for steps 0, 1, and 2
Use a loop to fill in the array for steps 3 to N
The number of ways to reach step i is the sum of the number of ways to reach step i-1 and i-2
Return the value at the Nth index of the array
Q36. Given 2 arrays of n and n - 1elements which have n - 1 in common find the unique elements
Given 2 arrays with n and n-1 elements, find the unique element in the larger array.
Loop through the larger array and check if each element is present in the smaller array.
If an element is not present in the smaller array, it is the unique element.
Return the unique element.
Example: arr1 = ['a', 'b', 'c', 'd'], arr2 = ['a', 'b', 'c'], unique element = 'd'
The buddy system has advantages like increased safety and support, but also drawbacks like dependency and lack of independence.
Advantages: increased safety, support, accountability, motivation
Disadvantages: dependency, lack of independence, potential for conflicts
Example: In a buddy system at work, colleagues can support each other in completing tasks and provide motivation to stay on track.
Example: However, relying too heavily on a buddy can lead to dependency and hinder ind...read more
Q38. What is a electric current how can much diffen the electricity current and thier parts of electric current?
Electric current is the flow of electric charge through a conductor.
Electric current is measured in amperes (A).
It is caused by the movement of electrons in a conductor.
There are two types of electric current - direct current (DC) and alternating current (AC).
DC flows in one direction, while AC changes direction periodically.
Electric current is made up of three main components - voltage, current, and resistance.
Ohm's Law (V = IR) describes the relationship between these compo...read more
Q39. What is a electronic device how can you define the electronic device how can use the electronic device and it's Parts?
An electronic device is a device that operates using electronic circuits and components to perform various functions.
An electronic device typically consists of a power source, input/output components, a processor, memory, and various other electronic components.
Examples of electronic devices include smartphones, laptops, tablets, and digital cameras.
Electronic devices can be used for communication, entertainment, data processing, and various other purposes.
The parts of an ele...read more
Classful addressing uses fixed length subnet masks, while classless addressing allows for variable length subnet masks.
Classful addressing divides IP addresses into classes (A, B, C, D, E) with fixed subnet masks.
Classless addressing allows for more efficient use of IP addresses by using variable length subnet masks.
Classful addressing can lead to wastage of IP addresses, while classless addressing is more flexible and scalable.
Classful addressing is outdated and not commonly...read more
Q41. What happens when an recursive function is called
A recursive function calls itself until a base case is reached, then returns the result to the previous call.
Each call creates a new instance of the function on the call stack
The function continues to call itself until a base case is reached
Once the base case is reached, the function returns the result to the previous call
The previous call then continues executing from where it left off
Memory protection in operating systems prevents one process from accessing or modifying the memory of another process.
Memory protection ensures that each process has its own isolated memory space.
It prevents unauthorized access to memory locations, improving system stability and security.
Operating systems use techniques like virtual memory and access control lists to enforce memory protection.
Examples include segmentation faults in Unix-like systems when a process tries to ac...read more
Q43. What is a critical rendering path?
The sequence of steps a browser takes to convert HTML, CSS, and JavaScript into a rendered page.
Includes parsing HTML, constructing the DOM tree, calculating styles, and executing JavaScript.
Optimizing the critical rendering path can improve page load times and user experience.
Examples of optimization techniques include minimizing render-blocking resources and using lazy loading.
The critical rendering path can vary depending on the browser and device being used.
Q44. what is the difference between docker swarm and docker compose ?
Docker Swarm is used for orchestrating multiple Docker containers across multiple hosts, while Docker Compose is used for defining and running multi-container Docker applications.
Docker Swarm is a container orchestration tool that allows you to manage a cluster of Docker hosts.
Docker Compose is a tool for defining and running multi-container Docker applications.
Docker Swarm is used for scaling and managing a cluster of Docker containers, while Docker Compose is used for defin...read more
Q45. Whole concept of VPC , subnet and route table and NAT gateway ?
VPC is a virtual private cloud that allows you to create isolated networks within the cloud environment. Subnets are subdivisions of a VPC, route tables define how traffic is directed within the VPC, and NAT gateway allows instances in a private subnet to access the internet.
VPC is a virtual private cloud that provides a logically isolated section of the AWS Cloud where you can launch resources.
Subnets are subdivisions of a VPC that allow you to group resources based on secur...read more
Q46. WHat is a DG Machine how can you find dg machine and it's Components and thier parts of dg machine?
A DG machine is a diesel generator machine used for generating electricity. Components include engine, alternator, fuel system, cooling system, and control panel.
DG machine stands for Diesel Generator machine.
Components include engine, alternator, fuel system, cooling system, and control panel.
Engine is the main component responsible for generating power.
Alternator converts mechanical energy from the engine into electrical energy.
Fuel system supplies diesel fuel to the engine...read more
Q47. WHAT Is a machine how can use machine and it's Components and technical Parts of machine?
A machine is a device that uses energy to perform a specific task by utilizing various components and technical parts.
Machines consist of components such as gears, motors, sensors, and actuators.
They operate based on principles of physics and engineering.
Examples include cars, computers, and industrial robots.
Q48. Write a program to find number of bits in a number.
Program to find number of bits in a number
Use bitwise operations to count the number of bits in a number
Iterate through each bit and count the set bits
Use log base 2 to find the number of bits in a number
The various types of inheritance in Object-Oriented Programming include single, multiple, multilevel, hierarchical, and hybrid inheritance.
Single inheritance: a class can inherit from only one base class.
Multiple inheritance: a class can inherit from multiple base classes.
Multilevel inheritance: a class can inherit from a class which is also derived from another class.
Hierarchical inheritance: multiple classes can inherit from a single base class.
Hybrid inheritance: a combina...read more
Q50. Link up all nodes present in same level of BST using next pointer
The question asks to link up all nodes present in the same level of a binary search tree using the next pointer.
Traverse the tree level by level using a queue
For each level, create a linked list by connecting the nodes using the next pointer
Use a dummy node to keep track of the start of the linked list for each level
Interview Questions of Similar Designations
Top Interview Questions for Member Technical Staff 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