Snapdeal
100+ Advanced Petro Services Interview Questions and Answers
Q1. Closest Pair of Points Problem Statement
Given an array containing 'N' points in a plane, your task is to find the distance between the closest pair of points.
Explanation:
The distance between two points, (x1,...read more
Find the distance between the closest pair of points in a plane given an array of points.
Calculate the distance between each pair of points using the formula provided.
Keep track of the minimum distance found so far.
Optimize the solution to avoid unnecessary calculations by considering only relevant pairs.
Consider using a data structure like a priority queue or sorting to improve efficiency.
Handle edge cases like when there are only two points in the array.
Q2. Count Set Bits Problem Statement
Given a positive integer N
, find the total number of '1's in the binary representation of all the numbers from 1 to N
.
You should return the result modulo 109+7 as the count can...read more
Count the total number of set bits in the binary representation of numbers from 1 to N, modulo 10^9+7.
Iterate through numbers from 1 to N and count the set bits in their binary representation
Use bitwise operations to count set bits efficiently
Return the total count modulo 10^9+7 as the result
Q3. Count Unique Rectangles in Grid
Given a grid with 'M' rows and 'N' columns, calculate the total number of unique rectangles that can be formed within the grid using its rows and columns.
Input:
The first line c...read more
Calculate the total number of unique rectangles that can be formed within a grid using its rows and columns.
Iterate through all possible combinations of rows and columns to calculate the number of unique rectangles
Use the formula (M * (M + 1) / 2) * (N * (N + 1) / 2) to find the total number of rectangles
Return the total number of unique rectangles for each test case
Q4. You have a deck of 10 cards.You take one card out and put it on table and put next card in the end of deck.You repeat this sequence till all cards are on the table.Sequence formed on the table is 1,2,3,4,5…10....
read moreReconstruct original sequence of cards given a specific sequence of cards placed on table.
The last card placed on the table must be 10.
The second last card placed on the table must be 5 or 6.
The first card placed on the table must be either 1 or 2.
Use trial and error method to reconstruct the original sequence.
Q5. LCA of Binary Tree Problem Statement
You are given a binary tree consisting of distinct integers and two nodes, X
and Y
. Your task is to find and return the Lowest Common Ancestor (LCA) of these two nodes.
The ...read more
Find the Lowest Common Ancestor (LCA) of two nodes in a binary tree.
Traverse the binary tree to find the paths from the root to nodes X and Y.
Compare the paths to find the last common node, which is the LCA.
Handle cases where one node is an ancestor of the other.
Consider edge cases like when X or Y is the root node.
Implement a recursive or iterative solution to find the LCA efficiently.
Q6. Find All Anagrams in a String
Given a string STR
and a non-empty string PTR
, your task is to identify all starting indices of PTR
’s anagrams in STR
.
Explanation:
An anagram of a string is another string that co...read more
Identify all starting indices of anagrams of a given string in another string.
Iterate through the main string using a sliding window approach.
Use a hashmap to keep track of characters in the anagram string.
Compare the hashmap of the anagram string with the current window of characters in the main string.
If the hashmaps match, add the starting index of the window to the result array.
Q7. Find Pair with Given Sum in BST
You are provided with a Binary Search Tree (BST) and a target value 'K'. Your task is to determine if there exist two unique elements in the BST such that their sum equals the ta...read more
Given a Binary Search Tree and a target value, determine if there exist two unique elements in the BST such that their sum equals the target.
Traverse the BST in-order to get a sorted array of elements.
Use two pointers approach to find the pair with the given sum.
Consider edge cases like null nodes and duplicate elements.
Q8. Zig Zag Tree Traversal Problem Statement
Given a binary tree, compute the zigzag level order traversal of the nodes' values. In a zigzag traversal, start at the root node and traverse from left to right at the ...read more
Zig Zag Tree Traversal involves alternating directions while traversing a binary tree level by level.
Implement a level order traversal of the binary tree.
Alternate the direction of traversal for each level.
Use a queue data structure to keep track of nodes at each level.
Handle null nodes appropriately to maintain the zigzag pattern.
Example: For input 1 2 3 4 -1 5 6 -1 7 -1 -1 -1 -1 -1 -1, the output should be 1 3 2 4 5 6 7.
Q9. Subtree Check in Binary Trees
You are given two binary trees, T and S. Your task is to determine whether tree S is a subtree of tree T, meaning S must match the structure and node values of some subtree in T.
I...read more
The task is to determine whether tree S is a subtree of tree T, matching structure and node values.
Parse the input level order traversal of both trees T and S
Check if tree S is a subtree of tree T by comparing their structures and node values
Output 'true' if S is a subtree of T, otherwise 'false'
Q10. Largest Rectangular Area In A Histogram
Given an array HEIGHTS
of length N
, where each element represents the height of a histogram bar and the width of each bar is 1, determine the area of the largest rectangl...read more
Find the largest rectangular area in a histogram given the heights of the bars.
Use a stack to keep track of the indices of the bars in non-decreasing order of heights.
Calculate the area of the rectangle with each bar as the smallest bar and update the maximum area.
Handle the case when the stack is not empty after processing all bars to calculate the remaining areas.
Example: For HEIGHTS = [2, 1, 5, 6, 2, 3], the largest rectangle has an area of 10.
Q11. Reverse a Linked List Problem Statement
You are given a Singly Linked List of integers. Your task is to reverse the Linked List by changing the links between nodes.
Input:
The first line of input contains a sin...read more
Reverse a given singly linked list by changing the links between nodes.
Iterate through the linked list and reverse the links between nodes.
Keep track of the previous, current, and next nodes while reversing the links.
Update the head of the linked list to point to the last node after reversal.
Q12. Linked List Cycle Detection
Determine if a given singly linked list of integers forms a cycle.
Explanation:
A cycle in a linked list occurs when a node's next reference points back to a previous node in the lis...read more
Detect if a singly linked list forms a cycle by checking if a node's next reference points back to a previous node.
Use two pointers, one moving at double the speed of the other, to detect a cycle.
If the two pointers meet at any point, there is a cycle in the linked list.
If one of the pointers reaches the end of the list (null), there is no cycle.
Q13. Inorder Traversal of Binary Tree Without Recursion
Given a Binary Tree consisting of 'N' nodes with integer values, your task is to perform an In-Order traversal of the tree without using recursion.
Input:
The ...read more
Perform in-order traversal of a binary tree without recursion.
Use a stack to simulate the recursive process of in-order traversal
Start with the root node and keep traversing left until reaching a null node, then pop from stack and move to right node
Keep track of visited nodes to avoid revisiting them
Return the in-order traversal list
Q14. Search in a Row-wise and Column-wise Sorted Matrix Problem Statement
You are given an N * N matrix of integers where each row and each column is sorted in increasing order. Your task is to find the position of ...read more
Given a sorted N * N matrix, find the position of a target integer 'X'.
Start from the top-right corner of the matrix and compare the target with the current element.
Based on the comparison, move left or down in the matrix to narrow down the search.
Repeat the process until the target is found or the search goes out of bounds.
Return the position of the target if found, else return {-1, -1}.
Q15. There is a file which contains ip addresses and corresponding url. Example 192.168.1.15 www.abc.com 10.255.255.40 ----- You have to return the subnet mask of the ip and the url after “www.” Output 192.168.1 abc...
read moreJava function to return subnet mask of IP and URL after www.
Read the file and store IP addresses and URLs in separate arrays
Use regex to extract subnet mask from IP address
Use substring to extract URL after www.
Return subnet mask and URL as separate strings
Q16. Nth Fibonacci Problem Statement
Calculate the Nth term of the Fibonacci series, denoted as F(n), using the formula: F(n) = F(n-1) + F(n-2)
where F(1) = 1
and F(2) = 1
.
Input:
The first line of each test case co...read more
Calculate the Nth term of the Fibonacci series using a recursive formula.
Use the formula F(n) = F(n-1) + F(n-2) to calculate the Nth Fibonacci number.
Start with base cases F(1) = 1 and F(2) = 1.
Continue recursively calculating Fibonacci numbers until reaching the desired N.
Ensure to handle edge cases and constraints such as 1 ≤ N ≤ 10000.
Q17. Find the Next Greater Number with the Same Set of Digits
Given a string S
that represents a number, determine the smallest number that is strictly greater than the original number and has the same set of digits...read more
The task is to find the smallest number greater than the given number with the same set of digits.
Sort the digits of the number in descending order.
Find the first digit from the right that is smaller than the digit to its right.
Swap this digit with the smallest digit to its right that is greater than it.
Sort all the digits to the right of the swapped digit in ascending order to get the smallest number greater than the original number.
Q18. Vertical Sum in a Binary Tree
Given a binary tree where each node has a positive integer value, compute the vertical sum of the nodes. The vertical sum is defined as the sum of all nodes aligned along the same ...read more
Compute the vertical sum of nodes in a binary tree aligned along the same vertical line.
Traverse the binary tree in a level order manner to calculate the vertical sum.
Use a hashmap to store the vertical sum at each vertical level.
Recursively traverse the tree and update the vertical sum in the hashmap.
Output the vertical sums in the required format for each test case.
Q19. How would you design DBMS for Snapdeal’s website’s shoe section. Now if you want to further break it into Sports and Casual Shoe would you break the DB into two or add another entity?
For Snapdeal's shoe section, I would design a DBMS with separate entities for Sports and Casual Shoes.
Create a main entity for shoes with attributes like brand, size, color, etc.
Create separate entities for Sports and Casual Shoes with attributes specific to each category.
Link the Sports and Casual Shoe entities to the main Shoe entity using a foreign key.
Use indexing and normalization techniques to optimize performance and reduce redundancy.
Consider implementing a search fea...read more
Q20. Balanced Parentheses Check
Given a string STR
consisting solely of the characters '{', '}', '(', ')', '[', and ']', determine whether the parentheses are balanced.
Input:
The first line contains an integer 'T' ...read more
Implement a function to check if parentheses in a string are balanced.
Use a stack to keep track of opening parentheses and pop when a closing parenthesis is encountered.
If the stack is empty when a closing parenthesis is encountered or if there are unmatched parentheses at the end, return 'NO'.
Ensure that all opening parentheses have a corresponding closing parenthesis in the correct order.
Return 'YES' if all parentheses are balanced.
Example: Input: {[()]}, Output: YES
Pick a fruit from the jar labeled 'Apples and Oranges' to correctly label all jars.
Pick a fruit from the jar labeled 'Apples and Oranges'.
If you pick an apple, label the jar as 'Apples'.
If you pick an orange, label the jar as 'Oranges'.
Label the remaining jars accordingly based on the above information.
Q22. Merge Two Sorted Arrays Problem Statement
Given two sorted integer arrays ARR1
and ARR2
of size M and N, respectively, merge them into ARR1
as one sorted array. Assume that ARR1
has a size of M + N to hold all ...read more
Merge two sorted arrays into one sorted array in place.
Iterate from the end of both arrays and compare elements to merge in place
Use two pointers to keep track of the current position in both arrays
Handle cases where one array is fully merged before the other
Q23. Maximum Level Sum in Binary Tree Problem Statement
Given an arbitrary binary tree consisting of N nodes, where each node is associated with a certain value, your task is to find the maximum sum for any level in...read more
Find the maximum sum for any level in a binary tree.
Traverse the binary tree level by level and calculate the sum for each level.
Keep track of the maximum sum encountered so far.
Return the maximum sum found.
Example: For the input tree, the maximum level sum is 13 (5+6+2).
Q24. Find Top K Frequent Numbers in a Stream
Given an integer array ARR
and an integer K
, your task is to find the K
most frequent elements in ARR
. Return the elements sorted in ascending order.
Example:
Input:
ARR ...read more
Find the K most frequent elements in an integer array and return them sorted in ascending order.
Use a hashmap to store the frequency of each element in the array.
Use a min heap to keep track of the K most frequent elements.
Return the elements from the min heap in ascending order.
Q25. You are given two ropes.Each rope takes exactly 1 hour to burn. How will you measure period of 45 minutes
Burn one rope from both ends and the other rope from one end.
Light one rope from both ends and the other rope from one end.
When the first rope burns completely, 30 minutes have passed.
Then, immediately light the other end of the second rope.
When the second rope burns completely, 15 more minutes have passed.
Total time elapsed is 45 minutes.
Q26. There are two sorted arrays. First one is of size m+n containing only ‘first’ m elements. Another one is of size n and contains n elements. Merge these two arrays into the first array of size m+n such that the...
read moreMerge two sorted arrays into one sorted array of larger size
Create a new array of size m+n
Compare the last elements of both arrays and insert the larger one at the end of the new array
Repeat until all elements are merged
If any elements are left in the smaller array, insert them at the beginning of the new array
Time complexity: O(m+n)
Example: arr1=[1,3,5,7,0,0,0], arr2=[2,4,6], output=[1,2,3,4,5,6,7]
Q27. Variation of -----/ Given a dictionary of words and a number n. Find count of all words in dictionary that can be formed by given number n
The question asks to find the count of words in a dictionary that can be formed by a given number.
Iterate through each word in the dictionary
Check if the characters in the word can be formed using the given number
Increment the count if the word can be formed
Q28. Cube with six colors how many different cubes can be obtained?
There are 6 colors, so 6^3 = 216 different cubes can be obtained.
The cube has 6 faces, each of which can be one of 6 colors.
Therefore, there are 6 options for the first face, 6 for the second, and 6 for the third.
To find the total number of possible cubes, we multiply these options together: 6 x 6 x 6 = 216.
Q29. DNS – Domain name servers : what are they , how do they operate?
DNS servers translate domain names into IP addresses to enable communication between devices on the internet.
DNS servers act as a phone book for the internet, translating domain names into IP addresses.
When a user types a domain name into their browser, the browser sends a request to a DNS server to resolve the domain name into an IP address.
DNS servers operate in a hierarchical system, with root servers at the top, followed by top-level domain servers, and then authoritative...read more
Q30. Calculate what single cut bookmyshow should charge from the customers depending on the various factor..... Ans. List the factors like movie of superstar, festival occasion etc.
BookMyShow should charge different prices based on factors like movie of superstar, festival occasion, etc.
Consider the popularity of the movie star
Take into account the demand for tickets during festival occasions
Analyze the competition and market trends
Offer discounts for bulk bookings or loyalty programs
Consider the cost of production and distribution
Adjust prices based on the time of day or week
Use dynamic pricing to optimize revenue
Examples: Charge higher prices for a mo...read more
Q31. How to eliminate a defective pack (empty) from a bunch of non-empty ones while loading for transportation?
Defective pack elimination during transportation loading
Inspect each pack before loading
Use a checklist to ensure all packs are accounted for
Separate defective packs from non-defective ones
Label defective packs clearly
Dispose of defective packs properly
Train personnel on proper handling procedures
Q32. How are you suppose to deal with a customer who is already pissed off with the previous executive that he/she had talked to?
When dealing with a customer who is already upset with a previous executive, it is important to empathize, listen actively, apologize if necessary, and offer a solution or escalate the issue if needed.
Empathize with the customer and acknowledge their frustration.
Listen actively to understand their concerns and let them vent if necessary.
Apologize for any inconvenience caused by the previous executive, even if it wasn't your fault.
Offer a solution or alternative to address the...read more
Q33. Lowest Common Ancestor of two nodes in binary tree.I wrote code for this.Then interviewer drew a tree and asked to print stacktrace on it
Finding lowest common ancestor of two nodes in binary tree
Traverse the tree from root to both nodes and store the paths in separate arrays
Compare the paths to find the last common node
Return the last common node as the lowest common ancestor
Use recursion to traverse the tree efficiently
Q34. Write a code to find if the input date is today or tomorrow based on the current date. If it's not today or tomorrow, output the no of days difference between the input date and the current date.
Code to find if input date is today/tomorrow or no of days difference from current date.
Get current date using Date() constructor
Convert input date to Date object
Compare input date with current date to check if it's today/tomorrow
If not, calculate the difference in days using getTime() method
Output the result accordingly
Q35. Find LCM of all numbers from 1 to n. Give an algorithm, then correctly estimate the time complexity
Algorithm to find LCM of all numbers from 1 to n and its time complexity
Find prime factors of all numbers from 1 to n
For each prime factor, find the highest power it appears in any number from 1 to n
Multiply all prime factors raised to their highest power to get LCM
Time complexity: O(n*log(log(n)))
Q36. Explain box model in css, and what is specificity in CSS. What are render-blocking statements?
Box model defines how elements are rendered in CSS. Specificity determines which CSS rule applies to an element. Render-blocking statements delay page rendering.
Box model includes content, padding, border, and margin.
Specificity is calculated based on the number of selectors and their types.
Render-blocking statements are CSS or JavaScript files that prevent the page from rendering until they are loaded.
Use media queries to optimize rendering and reduce render-blocking stateme...read more
Q37. calculate the top 10 words , which comes frequently in 1 hour time span , on facebook, (dynamically)
Calculate top 10 frequently used words on Facebook in 1 hour dynamically.
Use Facebook API to fetch data
Implement a script to count word frequency
Sort the words based on frequency and return top 10
Q38. What is event bubbling, event capturing and its use?
Event bubbling and event capturing are two mechanisms in JavaScript that describe the order in which events are handled.
Event bubbling is the process where an event is first captured by the innermost element and then propagated to its parent elements.
Event capturing is the opposite process where an event is first captured by the outermost element and then propagated to its child elements.
Event bubbling is the default behavior in most browsers.
Event.stopPropagation() can be us...read more
Q39. How will you implement infinite scrolling in react js?
Implement infinite scrolling in React JS using Intersection Observer API.
Use Intersection Observer API to detect when the user has scrolled to the bottom of the page.
Fetch new data and append it to the existing data using setState.
Use a loading spinner to indicate that new data is being fetched.
Add a debounce function to prevent multiple API calls while scrolling.
Use a key prop when rendering the list of data to avoid re-rendering of existing elements.
Q40. There is four digit number in aabb form and it is a perfect square.Find out the number
The number is 7744.
The number must end in 00 or 44.
The square root of the number must be a whole number.
The only possible number is 7744.
Q41. In a matrix of only 0’s and 1’s, where in each row, there are only 0’s first and then 1’s, find the row with maximum number of 1’s. [Start with right top corner O(m+n) ] [With Code]
Find the row with maximum number of 1's in a matrix of 0's and 1's.
Start from the top right corner of the matrix
If the current element is 1, move left in the same row
If the current element is 0, move down to the next row
Repeat until you reach the bottom left corner of the matrix
Q42. A linked list contains loop.Find the length of non looped linked list
To find the length of non-looped linked list, we need to traverse the list and count the number of nodes.
Traverse the linked list using a pointer and count the number of nodes until the end of the list is reached.
If a loop is encountered, break out of the loop and continue counting until the end of the list.
Return the count as the length of the non-looped linked list.
Use two identical wires to measure 45 minutes by burning them at different ends.
Burn one end of the first wire and both ends of the second wire simultaneously.
When the first wire burns completely (30 minutes), light the other end of the second wire.
When the second wire burns completely (15 minutes), 45 minutes have passed.
Q44. Tell about Saas( Syntactically Awesome Style Sheets)
Saas is a CSS preprocessor that extends the functionality of CSS with variables, mixins, and more.
Saas stands for Syntactically Awesome Style Sheets
It allows for the use of variables, mixins, and functions in CSS
Saas code must be compiled into CSS before it can be used in a web page
Saas is often used in conjunction with build tools like Gulp or Webpack
Q45. What are inner join and outer join in sql
Inner join returns only the matching rows between two tables, while outer join returns all rows from one table and matching rows from the other.
Inner join combines rows from two tables based on a matching column.
Outer join returns all rows from one table and matching rows from the other.
Left outer join returns all rows from the left table and matching rows from the right table.
Right outer join returns all rows from the right table and matching rows from the left table.
Full ou...read more
Q46. Two linked list are merging at a point.Find merging point
To find the merging point of two linked lists
Traverse both linked lists and find their lengths
Move the pointer of the longer list by the difference in lengths
Traverse both lists simultaneously until they meet at the merging point
Q47. Why Snapdeal (or whatever company it is)?
Snapdeal is a leading e-commerce company in India with a strong customer base and a wide range of products.
Snapdeal has a large customer base in India, which provides a great opportunity for growth and impact.
The company offers a wide range of products across various categories, catering to diverse customer needs.
Snapdeal has a strong presence in the e-commerce market, competing with other major players.
The company has a user-friendly platform and offers convenient payment op...read more
Q48. Write code to find if two objects are equal or not in javascript
Code to check equality of two objects in JavaScript
Use the JSON.stringify() method to convert the objects into strings
Compare the string representations of the objects using the === operator
If the strings are equal, the objects are considered equal
Q49. If a shipment is changed in between i.e. product is replaced by say, a soap how will you tackle this problem?
Q50. Codes for Post-Order, In-Order and Level-Order Traversal of a binary tree.P.S : These questions were asked to my friends
Codes for Post-Order, In-Order, and Level-Order Traversal of a binary tree.
Post-Order Traversal: Left subtree, Right subtree, Root
In-Order Traversal: Left subtree, Root, Right subtree
Level-Order Traversal: Visit nodes level by level, from left to right
Q51. What is bind in javascript and write its polyfill
Bind creates a new function with a specified 'this' value and arguments.
Bind returns a new function with the same body as the original function.
The 'this' value of the new function is bound to the first argument passed to bind().
The subsequent arguments are passed as arguments to the new function.
Polyfill for bind() can be created using call() or apply() methods.
Q52. Create Linked List without using the internal library and provide the functionality of add delete find.
Create Linked List without using internal library and provide add, delete, find functionality.
Create a Node class with data and next pointer
Create a LinkedList class with head pointer and methods to add, delete, and find nodes
Use a loop to traverse the list and perform operations
Handle edge cases such as adding to an empty list or deleting the head node
Q53. Estimate the costs of an Auto-Rickshaw driver. (No time frame)
Estimating the costs of an Auto-Rickshaw driver.
Consider fuel expenses for the auto-rickshaw.
Include maintenance and repair costs.
Factor in license and permit fees.
Account for insurance premiums.
Include daily wages for any helpers or assistants.
Consider miscellaneous expenses like parking fees and tolls.
Q54. Walk be through your CV and explain each thing in detail
I will explain each section of my CV in detail.
Education: I completed my Bachelor's degree in Economics at XYZ University. I focused on macroeconomics and econometrics, conducting research on the impact of fiscal policy on economic growth.
Internship: I interned at ABC Company, where I worked closely with the data analysis team. I gained hands-on experience in data collection, cleaning, and analysis using tools like Excel and SQL.
Work Experience: I worked as a Junior Analyst a...read more
Q55. You are receiving 0/1 in the left side of previous number dynamically and for each insert you have to print whether decimal of new generated number is divisible by 3. Print “YES” or “NO” accordingly
Check if the decimal of a dynamically generated number is divisible by 3 based on the left side of the previous number.
Generate new number by adding 0 or 1 to the left side of previous number
Check if the decimal of the new number is divisible by 3
Print 'YES' if divisible by 3, 'NO' otherwise
Q56. what is the difference between async and defer
async loads script while page continues to load, defer loads script after page has loaded
async loads scripts asynchronously while page continues to load
defer loads scripts after the page has loaded
async scripts may not execute in order, while defer scripts do
async scripts may cause rendering issues, while defer scripts do not
Q57. How would you tackle a problem from our brand loyal seller?
I would listen to their concerns, empathize with their situation, and work with them to find a solution that meets their needs.
Listen actively to understand their concerns
Acknowledge their loyalty to the brand
Empathize with their situation
Collaborate with them to find a solution that meets their needs
Provide options and alternatives if necessary
Follow up to ensure their satisfaction
Q58. Guess the amount of water used in the college?
The amount of water used in the college depends on various factors such as the number of students, staff, and facilities.
The amount of water used in the college varies depending on the size of the college.
The number of students, staff, and facilities also play a significant role in determining the amount of water used.
The college may have water-saving measures in place to reduce water usage.
The amount of water used may also vary depending on the season and weather conditions....read more
Q59. Mean median mode, why median is best
Median is best because it is not affected by outliers and gives a better representation of central tendency.
Median is the middle value in a dataset, which makes it less affected by extreme values or outliers.
It gives a better representation of central tendency as compared to mean, which can be skewed by outliers.
Mode is not always useful as it may not exist or may not be unique in a dataset.
For example, in a dataset of salaries, the median would give a better representation o...read more
Q60. You have an sorted array,you have to make a balanced binary search tree from it (only approach) and basic insertion and deletion in BST
To create a balanced binary search tree from a sorted array, use the middle element as the root and recursively build left and right subtrees.
Start with the middle element of the array as the root of the BST.
Recursively build the left subtree with elements to the left of the middle element.
Recursively build the right subtree with elements to the right of the middle element.
Q61. Calculate the level sum of the binary tree
Calculate the level sum of a binary tree.
Traverse the tree level by level using BFS
Add the values of nodes at each level
Store the level sum in an array
Return the array of level sums
Q62. SQL vs NoSQL. Why NoSQL
NoSQL databases are flexible, scalable, and can handle large amounts of unstructured data.
NoSQL databases are schema-less, allowing for easy and flexible data modeling.
They can handle large amounts of unstructured data, making them suitable for big data applications.
NoSQL databases are highly scalable and can easily handle high traffic and large user bases.
They provide horizontal scalability by distributing data across multiple servers.
NoSQL databases are often used in real-t...read more
Q63. Difference between Process and Thread.6. find the number occurring odd number of time (xor solution).-----/
XOR solution to find the number occurring odd number of times in an array.
Iterate through the array and XOR all elements together.
The result will be the number occurring odd number of times.
Example: [2, 2, 3, 3, 4] -> XOR of all elements = 4.
Q64. You have given two arrays, all the elements of first array is same as second array except 1, You have to find out distinct pair
Find the distinct pair in two arrays where all elements are same except one.
Iterate through both arrays and compare elements at each index.
If elements are not equal, those are the distinct pair.
Handle edge cases like empty arrays or arrays with different lengths.
Q65. Find the number of connected components [islands] in a matrix formed with only 0’s and 1’s. [With Code] -----/
Q66. Number of rectangles in MxN matrix
The number of rectangles in an MxN matrix can be calculated using a formula.
The formula is (M * (M + 1) * N * (N + 1)) / 4
The matrix can be divided into smaller sub-matrices to count the rectangles
The number of rectangles can also be calculated by counting all possible pairs of rows and columns
Q67. Find the total no of the island in a 2d matrix. Working code was required.
Find the total no of islands in a 2D matrix.
Use DFS or BFS to traverse the matrix.
Mark visited cells to avoid repetition.
Count the number of islands found.
Q68. If you recieve a damaged product, how will.you deal with customer over the phone?
I would apologize for the inconvenience and assure the customer that we will resolve the issue promptly.
Apologize for the inconvenience caused
Assure the customer that we will resolve the issue
Ask for details about the damaged product
Offer options for replacement, refund, or repair
Provide clear instructions on returning the damaged product
Q69. A simple program to check whether a number is palindrome or not
A program to check if a number is a palindrome or not.
Convert the number to a string
Reverse the string
Compare the reversed string with the original string
If they are the same, the number is a palindrome
Q70. Write a recursive function for nth fibonacci number!Now make some changes in the same code in order to get O(1) complexity in most cases.(Use Dynamic Programming!)
Q71. Given a 2-d array with sorted rows and columns, write efficient code for searching a number!Puzzle : a glass, a tap given! fill the glass half without the use of any measuring instruments!
Q72. A sorted Array has been rotated r times to the left. find the minimum in least possible time(O(logn) expected). -----/
Q73. How will you decide what data structure should use?
Q74. Find square root of a number
To find square root of a number, use Math.sqrt() function in JavaScript.
Use Math.sqrt() function in JavaScript to find square root of a number.
For example, Math.sqrt(16) will return 4.
If the number is negative, Math.sqrt() will return NaN.
Q75. Number of rectangles/squares in chess board
There are 204 squares and 1296 rectangles on a standard 8x8 chess board.
The number of squares can be calculated using the formula n(n+1)(2n+1)/6, where n is the number of rows/columns.
The number of rectangles can be calculated using the formula n(n+1)m(m+1)/4, where n and m are the number of rows and columns respectively.
For an 8x8 chess board, there are 64 squares of size 1x1, 49 squares of size 2x2, 36 squares of size 3x3, 25 squares of size 4x4, 16 squares of size 5x5, 9 s...read more
Q76. Design a recommendation system as you see on e-commerce sites recommending the items for you to buy. You just have to tell the ideas and design the classes accordingly
Q77. Number of Umbrella sold in India during rainy seasons
The number of umbrellas sold in India during rainy seasons varies depending on factors such as rainfall intensity and geographical location.
The demand for umbrellas is generally higher in regions with heavy rainfall.
Urban areas with higher population density may have a higher demand for umbrellas.
Factors like price, availability, and marketing strategies also influence umbrella sales.
Sales data from previous years can provide insights into the average number of umbrellas sold...read more
Q78. Which e-commerce site you normally purchase from and why?
An outer join combines rows from two tables even if there is no match between the columns being joined.
Returns all rows from both tables, filling in missing values with NULL
Useful for finding unmatched rows between two tables
Types of outer joins include LEFT OUTER JOIN, RIGHT OUTER JOIN, and FULL OUTER JOIN
Q80. What is pre-order and post-order?
Pre-order and post-order are traversal methods used in binary trees.
Pre-order: visit root, left subtree, right subtree
Post-order: visit left subtree, right subtree, root
Used to traverse binary trees and perform operations on nodes
Example: Pre-order traversal of binary tree: A, B, D, E, C, F, G
Example: Post-order traversal of binary tree: D, E, B, F, G, C, A
Inner Join is a SQL operation that combines rows from two tables based on a related column between them.
Inner Join returns only the rows that have matching values in both tables.
It is used to retrieve data that exists in both tables.
Example: SELECT * FROM table1 INNER JOIN table2 ON table1.column = table2.column;
Q82. Estimate the revenue of a Dominos outlet
Estimating the revenue of a Dominos outlet
Consider the average number of orders per day
Calculate the average order value
Multiply the average number of orders by the average order value
Take into account any seasonal variations or promotions
Consider the location and population density of the outlet
Analyze the competition in the area
Factor in the operating expenses and profit margin
Q83. Reverse linked list without recursion
Reverse a linked list iteratively
Create three pointers: prev, curr, and next
Initialize prev to null and curr to head
Loop through the list and set next to curr's next node
Set curr's next node to prev
Move prev and curr one step forward
Return prev as the new head
Q84. whether 899 is prime or not??
No, 899 is not a prime number.
A prime number is a positive integer greater than 1 that has no positive integer divisors other than 1 and itself.
899 can be divided by 29 and 31, so it is not a prime number.
Q85. Binary Search in Rotated sorted array. i.e. 567891234
Binary search in rotated sorted array involves finding a target element efficiently.
Identify the pivot point where the array is rotated
Determine which half of the array the target element lies in
Apply binary search in the appropriate half
Q86. Different types of traversals of a tree, with example
Tree traversals are methods used to visit each node in a tree data structure.
Inorder traversal: Visit left subtree, then root, then right subtree. Example: 1. Left -> Root -> Right
Preorder traversal: Visit root, then left subtree, then right subtree. Example: 1. Root -> Left -> Right
Postorder traversal: Visit left subtree, then right subtree, then root. Example: 1. Left -> Right -> Root
Q87. How you will improve health of a marketplace
By analyzing data, identifying pain points, and implementing solutions to improve user experience and trust.
Analyze user behavior and feedback to identify areas of improvement
Implement measures to increase transparency and trust, such as user reviews and seller verification
Provide resources and support for dispute resolution
Encourage diversity and inclusivity in the marketplace to attract a wider range of buyers and sellers
Regularly monitor and update policies to ensure compl...read more
Q88. How you will design new customer support system
I will design a customer support system that is user-friendly, efficient, and personalized.
Conduct research to understand customer needs and preferences
Identify common customer issues and develop a knowledge base for quick resolution
Implement a ticketing system to track and prioritize customer inquiries
Integrate chatbots and AI to provide 24/7 support
Train support staff to provide personalized and empathetic service
Collect feedback and analyze data to continuously improve the...read more
Q89. Binary Search in Biotonic sorted array. i.e. 12345XXXXX2
Binary search in a biotonic sorted array involves finding a target value in an array that first increases and then decreases.
Start by finding the peak element in the array to determine the increasing and decreasing halves.
Perform binary search on both halves separately to find the target value.
Example: Array 12345XXXXX2, target value 2. Peak element is 5, search left half (12345) and then right half (5432) for the target value.
Q90. What are tree traversals?
Tree traversals are methods of visiting all nodes in a tree data structure.
There are three types of tree traversals: in-order, pre-order, and post-order.
In-order traversal visits the left subtree, then the root, then the right subtree.
Pre-order traversal visits the root, then the left subtree, then the right subtree.
Post-order traversal visits the left subtree, then the right subtree, then the root.
Tree traversals are commonly used in searching and sorting algorithms.
Q91. What are the goals for the future?
To excel in my role and contribute to the growth of the company.
To learn and master new skills
To exceed performance expectations
To collaborate with team members and share knowledge
To contribute to the company's success through hard work and dedication
Q92. The architecture of the current system.
The current system follows a microservices architecture.
The system is divided into multiple independent services.
Each service has its own database and communicates with other services through APIs.
The architecture allows for scalability and flexibility.
Examples of microservices used in the system include user authentication, payment processing, and inventory management.
Q93. Check if a linked list is palindrome or not
The answer describes how to check if a linked list is a palindrome or not.
Traverse the linked list and store the values in an array
Compare the elements of the array from both ends to check for palindrome
Alternatively, use two pointers to traverse the linked list, one slow and one fast, and reverse the first half of the list while traversing
Q94. What are the demerits in SnapDeal?
Q95. Kth element from the end, of a linked list
To find the Kth element from the end of a linked list, we can use the two-pointer approach.
Initialize two pointers, 'fast' and 'slow', pointing to the head of the linked list.
Move the 'fast' pointer K steps ahead.
Move both 'fast' and 'slow' pointers one step at a time until 'fast' reaches the end of the linked list.
The 'slow' pointer will be pointing to the Kth element from the end.
TCP/IP is a set of protocols that governs the way data is transmitted over the internet.
TCP/IP stands for Transmission Control Protocol/Internet Protocol.
It is a suite of communication protocols used to connect devices on the internet.
TCP ensures that data is reliably transmitted between devices.
IP is responsible for addressing and routing data packets across networks.
Examples of TCP/IP protocols include HTTP, FTP, and SMTP.
Q97. Check whether or not a linked list has a loop
To check if a linked list has a loop, we can use the Floyd's cycle-finding algorithm.
Use two pointers, one moving at twice the speed of the other
If there is a loop, the fast pointer will eventually catch up with the slow pointer
If the fast pointer reaches the end of the list, there is no loop
Q98. Circular linkList meeting point and proof
Circular linked list meeting point and proof
To find the meeting point in a circular linked list, use Floyd's Tortoise and Hare algorithm
Start with two pointers, one moving at twice the speed of the other
When they meet, reset one pointer to the head and move both at the same speed until they meet again
The meeting point is the start of the loop in the linked list
Q99. Check if anagram of a string is palindrome or not
Q100. Short term & Long term aims in Life
Short term aim is to excel in my role as a business analyst and contribute to the success of the company. Long term aim is to become a senior business analyst and eventually a business consultant.
Short term aim: Excel in my role as a business analyst
Short term aim: Contribute to the success of the company
Long term aim: Become a senior business analyst
Long term aim: Transition into a business consultant role
Top HR Questions asked in Advanced Petro Services
Interview Process at Advanced Petro Services
Top Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month