i
Uplers
Filter interviews by
Design patterns in Laravel are reusable solutions to common problems in software design.
Design patterns help in organizing code and improving code reusability.
Some common design patterns in Laravel include Singleton, Factory, Repository, and Observer.
Singleton pattern ensures that only one instance of a class is created.
Factory pattern is used to create objects without specifying the exact class of object that will be ...
Facades in Laravel provide a simple and convenient way to access classes and services from the container.
Facades act as static proxies to underlying classes, allowing easy access to their methods.
They provide a clean and expressive syntax for accessing services.
Facades are used to access Laravel's core services, such as the database, cache, and session.
They can be used to access custom classes and services registered i...
I appeared for an interview in Aug 2017.
Merge Sort is a divide and conquer algorithm that sorts an array by dividing it into two halves, sorting them separately, and then merging the sorted halves.
Divide the array into two halves
Recursively sort the two halves
Merge the sorted halves
Find pairs of integers in a BST whose sum is equal to a given number.
Traverse the BST and store the values in a hash set.
For each node, check if (X - node.value) exists in the hash set.
If yes, add the pair (node.value, X - node.value) to the result.
Continue traversal until all nodes are processed.
Merge overlapping time intervals into mutually exclusive intervals.
Sort the intervals based on their start time.
Iterate through the intervals and merge overlapping intervals.
Output the mutually exclusive intervals.
Example: [(1,3), (2,6), (8,10), (15,18)] -> [(1,6), (8,10), (15,18)]
Different types of hashing and alternative for Linear Chaining
Different types of hashing include division, multiplication, and universal hashing
Alternative for Linear Chaining is Open Addressing
Open Addressing includes Linear Probing, Quadratic Probing, and Double Hashing
An AVL tree is a self-balancing binary search tree where the heights of the left and right subtrees differ by at most one.
AVL tree is a binary search tree with additional balance factor for each node.
The balance factor is the difference between the heights of the left and right subtrees.
Insertion and deletion operations in AVL tree maintain the balance factor to ensure the tree remains balanced.
Rotations are performed ...
Find the minimum number of squares whose sum equals to a given number n.
Use dynamic programming to solve the problem efficiently.
Start with finding the square root of n and check if it is a perfect square.
If not, then try to find the minimum number of squares required for the remaining number.
Repeat the process until the remaining number becomes 0.
Return the minimum number of squares required for the given number n.
Insertion sort for a singly linked list.
Traverse the list and compare each node with the previous nodes
If the current node is smaller, swap it with the previous node
Repeat until the end of the list is reached
Time complexity is O(n^2)
Reverse a binary search tree while maintaining parent-child relationship.
Start by swapping the left and right child of each node recursively.
Use a depth-first search approach to traverse the tree.
Make sure to update the parent-child relationships accordingly.
To find min and max element in stack in O(1), we can use an auxiliary stack.
Create an auxiliary stack to keep track of the minimum and maximum elements.
Push the first element to both the main and auxiliary stack.
For each subsequent element, compare it with the top element of the auxiliary stack and push the smaller element to the auxiliary stack.
To get the minimum element, simply return the top element of the auxiliary...
Given an array, find the next minimum element for each element.
Iterate through the array
For each element, compare it with the elements on its right
Find the minimum element greater than the current element
If no such element exists, assign -1
Build the resultant array
Find median of input stream in minimum time complexity using online algorithm.
Use two heaps, one max heap for elements smaller than current median and one min heap for elements greater than current median.
Maintain balance between the two heaps by ensuring that the size difference is at most 1.
If the size of both heaps is equal, median is the average of the top elements of both heaps. Else, median is the top element of ...
To make a copy of a linked list with two pointers, iterate through the original list and create a new node for each element.
Iterate through the original linked list
Create a new node for each element
Set the 'next' pointer of each new node
Set the 'arbitrary' pointer of each new node
Reverse the nodes of a linked list in pairs of n
Iterate through the linked list in pairs of n
Reverse the nodes within each pair
Connect the reversed pairs together
Handle cases where the number of nodes is not a multiple of n
To check if a singly linked list is a palindrome, reverse the second half and compare it with the first half.
Traverse the linked list to find the middle node
Reverse the second half of the linked list
Compare the reversed second half with the first half to check for palindrome
Given a preorder of binary tree with leaf nodes represented by N, construct the tree.
Start by creating an empty stack.
Iterate through the preorder list.
If the current element is N, create a leaf node and push it onto the stack.
If the current element is not N, create a new node and set its left child to the top of the stack.
Pop the top of the stack and set it as the right child of the new node.
Push the new node onto the...
The question asks to find the maximum occupancy word in each line of a given multiline string and also count the occupancy of capital and small letters separately.
Split the multiline string into individual lines
For each line, split it into words
Initialize variables to store the maximum occupancy word and its count
Iterate through each word and count the occupancy of each letter
If the current word has a higher occupancy ...
Algorithm to find the best buying and selling dates for maximum profit from given stock prices array.
Iterate through the array and keep track of minimum price and maximum profit.
If current price is less than minimum price, update minimum price.
If current price minus minimum price is greater than maximum profit, update maximum profit and buying and selling dates.
Return buying and selling dates.
Example: [10, 7, 5, 8, 11,...
The code finds the number of ways to reach n steps by jumping 1 or 2 steps at a time.
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 0 and 1 steps
Iterate through the array and calculate the number of ways for each step
Return the value at the last step
Amazon.com is an online retail giant with a vast selection of products and services.
Advantages: Wide selection of products, competitive pricing, fast shipping, convenient shopping experience
Disadvantages: Can put smaller retailers out of business, concerns over worker treatment and environmental impact
Example: Amazon Prime offers free two-day shipping and access to streaming services like Prime Video and Music
Example: ...
Use file locking mechanisms like flock or lockfile to make a file mutually exclusive on a shared file system.
Use flock or lockfile to acquire a lock on the file before accessing it.
Release the lock once the operation is complete.
Ensure all processes accessing the file use the same locking mechanism.
Example: flock /path/to/file -c 'command to execute'
Example: lockfile /path/to/file && command to execute && rm -f /path/t
I am a software developer with 5 years of experience in developing web applications using Java and JavaScript.
5 years of experience in software development
Proficient in Java and JavaScript
Developed web applications
Strong problem-solving skills
Experience with agile development methodologies
Positive: Strong problem-solving skills, Negative: Can be overly critical of own work
Positive: Strong problem-solving skills - I excel at breaking down complex problems and finding efficient solutions
Negative: Can be overly critical of own work - I tend to be perfectionistic and struggle with accepting imperfections
I had a failure in implementing a new feature due to a lack of understanding of the requirements.
I was assigned to develop a new feature for our software application.
I misunderstood the requirements and implemented the feature incorrectly.
During the testing phase, it was discovered that the feature was not functioning as expected.
I took responsibility for the mistake and immediately communicated it to my team lead.
I wo...
Replace every element in array with its closest maximum element in right.
Iterate through the array from right to left
Keep track of the maximum element seen so far
Replace each element with the maximum element seen so far
Designing a distributed Hashtable and discussing its pros and cons.
Distributed Hashtable is a data structure that stores key-value pairs across multiple nodes.
Pros include scalability, fault tolerance, and load balancing.
Cons include increased complexity, potential for data inconsistency, and slower performance due to network communication.
Examples of distributed Hashtable implementations include Cassandra, Riak, and D
To identify if a tree is a BST, check if the inorder traversal of the tree results in a sorted sequence.
Perform an inorder traversal of the tree
Check if the resulting sequence is sorted in ascending order
If yes, the tree is a BST; otherwise, it is not
My favorite subject is computer science and I excel in problem-solving and algorithm design.
Computer science is my favorite subject because I enjoy coding and creating software applications.
I am best at problem-solving, as I have a strong analytical mindset and can efficiently break down complex issues.
I excel in algorithm design, as I have a deep understanding of data structures and can optimize code for efficiency.
Paging is a memory management technique used by operating systems to manage memory more efficiently. Virtual memory is a technique that allows a computer to use more memory than it physically has available.
Paging divides memory into fixed-size blocks called pages.
Virtual memory allows programs to use more memory than is physically available by temporarily transferring pages of data from RAM to disk.
Virtual memory also ...
The remaining memory is not wasted, but reserved for other system processes and applications.
The operating system reserves a portion of the RAM for its own processes and functions.
The unused memory can be used for caching data, improving system performance.
Applications and processes may not require the full amount of RAM at all times.
The unused memory can be allocated to other applications when needed.
Virtual memory an...
Return the total possible positions for a knight on a chess board given the number of combinations of moves.
Calculate all possible positions for a knight on a chess board using its unique L-shaped moves.
Consider the boundaries of the chess board while calculating the positions.
The total possible positions for a knight on a chess board are 64.
Use file locking mechanism to ensure mutual exclusion.
Implement file locking mechanism to prevent simultaneous access to files.
Use semaphores or mutexes to ensure only one process can access a file at a time.
Implement a queue system to handle multiple requests and process them one by one.
Use transactional file systems to ensure atomicity of file operations.
Implement a timeout mechanism to prevent deadlocks.
Consider imp...
Implementing a hash table in code
Choose a hash function to map keys to indices in the table
Create an array to hold the values at each index
Handle collisions by using a collision resolution strategy
Implement methods for inserting, retrieving, and deleting values
Consider load factor and resizing the table if necessary
The given question asks to replace the value in each node of a binary search tree with the sum of all nodes greater than the current node.
Traverse the BST in reverse order (right, root, left)
Keep track of the sum of all greater nodes encountered so far
Update the value of each node with the sum and update the sum
The next inorder predecessor in a binary search tree (BST) is the node with the largest value smaller than the given node.
In a BST, the inorder predecessor of a node is the rightmost node in its left subtree.
If the left subtree of the given node is empty, then the inorder predecessor is the nearest ancestor whose right child is also an ancestor of the given node.
If there is no inorder predecessor (i.e., the given node
Generate all possible parentheses for a given integer n.
Use recursion to generate all possible combinations of parentheses.
Start with an empty string and keep adding opening and closing parentheses.
Keep track of the number of opening and closing parentheses used.
Stop recursion when the number of opening and closing parentheses reaches n.
Add the generated combination to the result array.
The question asks how to feed a 2D matrix with values based on the given binary tree.
Traverse the binary tree and for each node, update the corresponding row in the matrix
Use a recursive function to update the matrix values
Start with the root node and recursively update its descendants
Set M[i, j] to 1 if node i is an ancestor of node j
Repeat the process for all nodes in the binary tree
Find the first occurrence of a given key element in a sorted array with duplicates.
Use binary search to find the key element.
If the key element is found, check if it is the first occurrence by checking the previous element.
If the key element is not found, return -1.
Spiral order traversal of a binary tree
Use a stack and a queue to traverse the binary tree in a spiral order
Start with the root node and add it to the stack
While the stack is not empty, pop a node from the stack and add its children to the queue
If the stack is empty, swap the stack and queue
Repeat until both stack and queue are empty
Queue can be implemented using two stacks by maintaining the order of elements.
Use two stacks, one for enqueue operation and one for dequeue operation
When enqueue is called, push the element onto the enqueue stack
When dequeue is called, if the dequeue stack is empty, transfer all elements from enqueue stack to dequeue stack
Pop the top element from the dequeue stack and return it as the dequeued element
Edit distance problem is a dynamic programming problem to find the minimum number of operations required to transform one string into another.
The problem can be solved using dynamic programming approach
The solution involves filling up a matrix of size (m+1)x(n+1)
The matrix represents the minimum number of operations required to transform one string into another
The operations include insertion, deletion and substitution
...
To find a loop in a linked list, we can use the Floyd's cycle-finding algorithm.
Initialize two pointers, slow and fast, both pointing to the head of the linked list.
Move slow pointer by one step and fast pointer by two steps at each iteration.
If there is a loop, the slow and fast pointers will eventually meet.
To prove the algorithm, we can use mathematical induction and the concept of tortoise and hare.
Return all root to leaf node paths of a binary tree with row, col and value.
Traverse the binary tree recursively and keep track of the current path.
When a leaf node is reached, add the path to the result.
Include row, col and value of each node in the path.
Use a data structure like a list or array to store the paths.
Consider edge cases like empty tree or single node tree.
Use an auxiliary stack to keep track of the maximum element at each step.
Create an auxiliary stack to store the maximum element at each step.
When pushing an element onto the main stack, compare it with the top element of the auxiliary stack.
If the new element is greater, push it onto the auxiliary stack.
When popping an element from the main stack, also pop the top element from the auxiliary stack if they are equal.
To g...
Implement a getMax() function for a queue that returns the maximum element in O(1) time complexity.
Maintain a separate data structure (e.g., a max heap) to track the maximum element in the queue.
Whenever an element is enqueued, compare it with the current maximum and update if necessary.
When dequeuing, check if the dequeued element is the maximum and update the maximum if needed.
Find the Next Greatest Element to the right for each element in an array.
Iterate through the array from right to left
Use a stack to keep track of elements
Pop elements from stack until a greater element is found
If no greater element is found, assign -1
Reverse the result array
Remove unnecessary parenthesis from an expression.
Identify the innermost expression enclosed in parenthesis.
Check if the parenthesis are necessary for evaluation.
If not, remove the parenthesis and repeat the process.
Stop when no more unnecessary parenthesis are found.
Find the maximum product of three integers in an array.
Sort the array in descending order.
Check the product of the first three numbers and the product of the first and last two numbers.
Return the maximum product.
Handle negative numbers by checking the product of two smallest negative numbers and the largest positive number.
The length of the longest consecutive subarray forming an arithmetic progression in an array of integers.
Iterate through the array and keep track of the longest consecutive subarray forming an AP.
Use a hashmap to store the difference between each element and the previous element.
If the difference is the same as the previous difference, increment the length of the current subarray.
If the difference is different, update ...
The algorithm finds the position of the 3rd occurrence of 'B' in an n-ary tree from a given index in constant time complexity.
Traverse the n-ary tree using a depth-first search (DFS) algorithm
Keep track of the count of 'B' occurrences
When the count reaches 3, return the current position
If the end of the tree is reached before the 3rd 'B', return -1
Check if a given string is a composite of two words from a limited dictionary.
Create a hash set of all the words in the dictionary.
Iterate through all possible pairs of substrings in the given string.
Check if both substrings are present in the hash set.
If yes, return true. Else, return false.
Switch adjacent nodes in a single linked list.
Traverse the linked list and swap adjacent nodes.
Keep track of previous node to update its next pointer.
Handle edge cases for first two nodes and last node.
Example: 1->2->3->4 becomes 2->1->4->3.
Traverse only the left sub-tree of a binary search tree.
Start at the root node
If the left child exists, visit it and repeat the process
If the left child does not exist, return to the parent node
Continue until all nodes in the left sub-tree have been visited
Design an efficient data structure for two lifts in a building of n floors.
Use a priority queue to keep track of the floors each lift is heading to
Implement a scheduling algorithm to determine which lift to assign to a new request
Consider adding a weight limit to each lift to prevent overloading
Use a hash table to keep track of the current location of each lift
To find the maximum number that can be formed from the digits of an integer.
Convert the integer to a string
Sort the characters in descending order
Join the sorted characters to form the maximum number
based on 1 interview
Interview experience
Project Coordinator
55
salaries
| ₹2.8 L/yr - ₹10 L/yr |
Talent Acquisition Executive
50
salaries
| ₹2.7 L/yr - ₹4.8 L/yr |
Html Developer
39
salaries
| ₹1.9 L/yr - ₹6.3 L/yr |
SEO Analyst
38
salaries
| ₹3 L/yr - ₹8.6 L/yr |
Talent Acquisition Specialist
22
salaries
| ₹2.7 L/yr - ₹6 L/yr |
Amazon
Udaan
Uber
Fareportal