PubMatic
30+ Annapoorna Mithai Interview Questions and Answers
Q1. Binary Tree Zigzag Traversal Problem Statement
Given a Binary Tree comprised of 'N' nodes with integer values, your task is to print the zigzag traversal of the tree.
Note:
The zigzag pattern implies that the f...read more
Q2. Convert Binary Tree to Mirror Tree
Convert a given binary tree into its mirror tree, where the left and right children of all non-leaf nodes are interchanged.
Input:
An integer ‘T’ denoting the number of test c...read more
Q3. Which coding language do you prefer and why?
I prefer Python because of its simplicity, readability, and extensive libraries.
Python is known for its simplicity and readability, making it easier to write and understand code.
Python has a large number of libraries and frameworks that can be used to quickly develop applications.
Python's syntax is clean and concise, allowing for faster development and easier maintenance.
Python is widely used in various domains such as web development, data analysis, and machine learning.
Pyth...read more
Q4. Time to Burn Tree Problem
You are given a binary tree consisting of 'N' unique nodes and a start node where the burning will commence. The task is to calculate the time in minutes required to completely burn th...read more
Q5. Loot Houses Problem Statement
A thief is planning to steal from several houses along a street. Each house has a certain amount of money stashed. However, the thief cannot loot two adjacent houses. Determine the...read more
Q6. Trailing Zeros in Factorial Problem
Find the number of trailing zeroes in the factorial of a given number N
.
Input:
The first line contains an integer T
representing the number of test cases.
Each of the followi...read more
Q7. What if person mistakenly put F for male and M for female in sql how do you solve this
To solve the issue of mistakenly assigned gender values in SQL, you can update the incorrect values using SQL queries.
Identify the incorrect gender values in the SQL table
Use UPDATE statement with appropriate conditions to correct the values
For example, if 'F' is mistakenly assigned for male, update it to 'M' using UPDATE statement
Q8. Topological Sort Problem Statement
Given a Directed Acyclic Graph (DAG) consisting of V
vertices and E
edges, your task is to find any topological sorting of this DAG. You need to return an array of size V
repr...read more
Q9. write a code using multithreading to scan 3 log files for different patterns and write the matches in a o/p file. these log files are huge, so code should not leave a huge memory foot print
Code using multithreading to scan 3 log files for different patterns and write matches in o/p file with low memory footprint.
Use Python's threading module to create multiple threads for each log file
Use regex to search for patterns in each log file
Write matches to output file using a thread-safe queue
Use a memory-efficient data structure like deque to store log file lines
Q10. how can you simulate 1 user profile to another user
Simulating one user profile to another can be done through user impersonation.
User impersonation can be achieved through various tools and techniques.
One way is to use a proxy server to intercept and modify the user's requests and responses.
Another way is to use a browser extension or plugin that allows you to switch between user profiles.
You can also use a testing tool like Selenium to automate the process of switching between user profiles.
It's important to ensure that the ...read more
Q11. write a code that should run as a service to scan every 30 sec to get min, max and avg CPU/memory and also calculate moving avg of last 300 sec.
Code to run as a service to scan CPU/memory every 30 sec and calculate min, max, avg and moving avg of last 300 sec.
Use a loop to run the code every 30 sec
Use psutil library to get CPU/memory usage
Store the values in a list and calculate min, max, avg and moving avg using numpy library
Use threading to run the code in the background as a service
Q12. Count the occurances a purticualar word from a file.
Count the occurrences of a particular word from a file.
Read the file and store its contents in a string variable.
Split the string into an array of words using a delimiter.
Loop through the array and count the occurrences of the particular word.
Return the count.
Q13. what is multiprocessing and multi threading
Multiprocessing is the use of multiple processors to execute multiple tasks simultaneously. Multithreading is the use of multiple threads within a single process to execute multiple tasks simultaneously.
Multiprocessing involves the use of multiple processors or cores to execute multiple tasks simultaneously.
Multithreading involves the use of multiple threads within a single process to execute multiple tasks simultaneously.
Multiprocessing is typically used for CPU-intensive ta...read more
Q14. Optimize an existing system. The system currently makes an API call and stores data in its memory. When it tries to serve a request from another component it refers to the memory location by searching the entir...
read moreImplement a data structure like a hash table or a cache to optimize memory search.
Use a hash table to store the data with keys as memory locations
Implement a cache to store frequently accessed data for faster retrieval
Consider using indexing or sorting techniques to optimize search operations
Q15. Write a code in c c++ or any other language to validate all use cases for an ip address given as input string. Output will be yes or no.
Code to validate all use cases for an IP address input string and output yes or no.
Use regular expressions to match the input string against the valid IP address pattern.
Check for valid ranges of each octet (0-255) and proper formatting (4 octets separated by periods).
Handle edge cases like leading zeros, extra spaces, and invalid characters.
Return 'yes' if the input string is a valid IP address, otherwise return 'no'.
Q16. Have you used fluient wait in selenium and why we are not using mostly
Fluent wait in Selenium is used for handling dynamic elements and synchronization issues.
Fluent wait is used to wait for a condition to be true before proceeding with the next steps in Selenium automation scripts.
It provides more flexibility in defining wait conditions compared to implicit or explicit waits.
Fluent wait can be used to wait for a specific element to be visible, clickable, or any other custom condition.
It is not used as frequently because it can lead to longer e...read more
Q17. find the number of pairs which sum to target.
Count pairs in an array that sum up to a target value.
Iterate through the array and store the frequency of each element in a hashmap.
For each element, check if the difference between the target and the element exists in the hashmap.
Increment the count of pairs if the difference is found in the hashmap.
Q18. Given 2 sorted integer array print the common value between them. 2 to 3 optimized ways.
Find common values in two sorted integer arrays efficiently.
Use two pointers approach to iterate through both arrays simultaneously.
If the current values are equal, add it to the result and move both pointers forward.
If the current values are not equal, move the pointer of the array with the smaller value forward.
Q19. Data structure with code writing
Implement a stack data structure using an array of strings.
Use an array to store the strings in the stack.
Implement push() and pop() functions to add and remove elements from the stack.
Keep track of the top of the stack using a variable.
Q20. Binary search moderate problems of array ones increasing then decreasing
Binary search can be used to solve moderate problems of arrays that are first increasing and then decreasing.
Use binary search to find the peak element in the array, which marks the transition from increasing to decreasing.
Divide the array into two parts based on the peak element and apply binary search on each part separately.
Handle edge cases such as when the array is strictly increasing or strictly decreasing.
Example: ['1', '3', '5', '7', '6', '4', '2']
Q21. what is bashrc .profile file
bashrc and .profile are configuration files for the Bash shell in Linux/Unix systems.
bashrc is executed for every new interactive shell session
.profile is executed only once during login
They contain environment variables, aliases, and other shell settings
bashrc is typically used for user-specific settings, while .profile is system-wide
Examples: setting PATH variable, defining aliases, setting prompt
Q22. smallest subarray having given target sum
Find the smallest subarray in an array that has a given target sum.
Use a sliding window approach to find the subarray with the target sum.
Keep track of the current sum of elements in the window and adjust the window size accordingly.
Start with a window of size 1 and expand it until the sum is greater than or equal to the target sum.
Shrink the window from the left side while updating the smallest subarray length until the sum is less than the target sum.
Q23. How to get all the links available in the page
To get all the links available on a page, you can use web scraping techniques.
Use a web scraping tool like BeautifulSoup in Python or Selenium to extract all the links from the page
Identify the HTML elements that contain the links, such as tags with href attributes
Iterate through the elements to extract the URLs and store them in a list
Q24. 1. longest path from node to node in tree
The longest path from one node to another in a tree is the maximum number of edges that must be traversed to reach from one node to another.
The longest path in a tree is also known as the diameter of the tree.
The diameter of a tree can be found by first finding the farthest leaf node from any arbitrary node, and then finding the farthest leaf node from that leaf node.
The sum of the distances from the root to the farthest leaf nodes in both subtrees of the root gives the diame...read more
Q25. Loop in kinked list
Detecting a loop in a linked list
Use two pointers, one moving at double the speed of the other
If there is a loop, the two pointers will eventually meet
Use Floyd's Cycle Detection Algorithm for efficient solution
Q26. system design for a web surfing utility
Design a system for a web surfing utility
Use a web crawler to gather data from websites
Implement a search engine to retrieve relevant information
Utilize a recommendation system to suggest related content
Include user authentication and personalized settings
Ensure scalability and performance for handling large amounts of data
Q27. What is Apache Kafka?
Apache Kafka is a distributed streaming platform used for building real-time data pipelines and streaming applications.
Apache Kafka is designed to handle high-throughput, fault-tolerant, and scalable real-time data streams.
It allows for the publishing and subscribing to streams of records, similar to a message queue.
Kafka is often used for log aggregation, stream processing, event sourcing, and real-time analytics.
It provides durability and fault tolerance through replication...read more
Q28. Java code for reverse string without split
Java code to reverse a string without using split method
Create a char array from the input string
Use two pointers to swap characters from start and end of the array
Continue swapping until the pointers meet in the middle
Q29. Count number of digits
Count the number of digits in a given string
Iterate through each character in the string
Check if the character is a digit using isdigit() function
Increment a counter if the character is a digit
Return the final count of digits
Q30. Java coding for array duplicates
Java code to find duplicates in an array of strings
Iterate through the array and use a HashSet to keep track of unique elements
If an element is already in the HashSet, it is a duplicate
Print or store the duplicates as needed
Q31. Sourcing for Java folks
Utilize various sourcing methods to find qualified Java candidates
Utilize job boards like Indeed and LinkedIn to search for Java developers
Attend Java meetups and conferences to network with potential candidates
Utilize social media platforms like Twitter and GitHub to find Java developers
Partner with coding bootcamps and universities to find recent Java graduates
Q32. Designing of chess
Designing a chess game involves creating a board with 64 squares, defining the movement rules for each piece, implementing game logic, and designing a user interface.
Create a 8x8 board with alternating colors for squares
Define movement rules for each type of chess piece (pawn, rook, knight, bishop, queen, king)
Implement game logic for capturing pieces, checkmate, stalemate
Design a user interface for players to interact with the game
Interview Process at Annapoorna Mithai
Top Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month