Add office photos
Premium Employer

Myntra

4.0
based on 1.9k Reviews
Video summary
Filter interviews by

60+ Meesho Interview Questions and Answers

Updated 1 Sep 2024
Popular Designations

Q1. Rearrange Array: Move Negative Numbers to the Beginning

Given an array ARR consisting of N integers, rearrange the elements such that all negative numbers are located before all positive numbers. The order of e...read more

Ans.

Yes, this can be achieved by using a two-pointer approach to rearrange the array in-place with O(1) auxiliary space.

  • Use two pointers, one starting from the beginning and one from the end of the array.

  • Move the left pointer to the right until it encounters a positive number, and the right pointer to the left until it encounters a negative number.

  • Swap the elements at the left and right pointers, and continue this process until the pointers meet.

  • The resulting array will have all ...read more

View 1 answer

Q2. Reverse Linked List Problem Statement

Given a singly linked list of integers, return the head of the reversed linked list.

Example:

Initial linked list: 1 -> 2 -> 3 -> 4 -> NULL
Reversed linked list: 4 -> 3 -> 2...read more
Ans.

Reverse a singly linked list of integers and return the head of the reversed linked list.

  • Iterate through the linked list and reverse the pointers to point to the previous node instead of the next node.

  • Use three pointers to keep track of the current, previous, and next nodes while reversing the linked list.

  • Update the head of the reversed linked list as the last node encountered during the reversal process.

Add your answer

Q3. Pair Sum Problem Statement

You are given an integer array 'ARR' of size 'N' and an integer 'S'. Your task is to find and return a list of all pairs of elements where each sum of a pair equals 'S'.

Note:

Each pa...read more

Ans.

Find pairs of elements in an array that sum up to a given value, sorted in a specific order.

  • Iterate through the array and use a hashmap to store the difference between the target sum and each element.

  • Check if the difference exists in the hashmap, if so, add the pair to the result list.

  • Sort the result list based on the criteria mentioned in the problem statement.

Add your answer

Q4. Dijkstra's Shortest Path Problem

Given an undirected graph with ‘V’ vertices (labeled 0, 1, ... , V-1) and ‘E’ edges, where each edge has a weight representing the distance between two connected nodes (X, Y).

Y...read more

Ans.

Dijkstra's algorithm is used to find the shortest path from a source node to all other nodes in a graph with weighted edges.

  • Implement Dijkstra's algorithm to find the shortest path distances from the source node to all other nodes in the graph.

  • Use a priority queue to efficiently select the next node with the shortest distance.

  • Update the distances of neighboring nodes based on the current node's distance and edge weights.

  • Handle disconnected vertices by assigning a large value ...read more

Add your answer
Discover Meesho interview dos and don'ts from real experiences

Q5. Sum of Maximum and Minimum Elements Problem Statement

Given an array ARR of size N, your objective is to determine the sum of the largest and smallest elements within the array.

Follow Up:

Can you achieve the a...read more

Ans.

Find sum of maximum and minimum elements in an array with least number of comparisons.

  • Iterate through the array and compare each element with current maximum and minimum to update them.

  • Initialize max as smallest possible value and min as largest possible value.

  • Return the sum of max and min after iterating through the array.

Add your answer

Q6. Preorder Traversal of a BST Problem Statement

Given an array PREORDER representing the preorder traversal of a Binary Search Tree (BST) with N nodes, construct the original BST.

Each element in the given array ...read more

Ans.

Given preorder traversal of a BST, construct the BST and return its inorder traversal.

  • Create a binary search tree from the preorder traversal array

  • Return the inorder traversal of the constructed BST

  • Ensure each element in the array is distinct

Add your answer
Are these interview questions helpful?

Q7. BFS Traversal in a Graph

Given an undirected and disconnected graph G(V, E) where V vertices are numbered from 0 to V-1, and E represents edges, your task is to output the BFS traversal starting from the 0th ve...read more

Ans.

BFS traversal in a disconnected graph starting from vertex 0.

  • Use a queue to keep track of nodes to visit next in BFS traversal

  • Start traversal from vertex 0 and explore its neighbors first

  • Continue exploring neighbors level by level until all nodes are visited

  • Ensure to print connected nodes in numerical sort order

Add your answer

Q8. Problem: Search In Rotated Sorted Array

Given a sorted array that has been rotated clockwise by an unknown amount, you need to answer Q queries. Each query is represented by an integer Q[i], and you must determ...read more

Ans.

Search for integers in a rotated sorted array efficiently.

  • Given a rotated sorted array, perform binary search for each query integer.

  • Maintain left and right pointers to search efficiently.

  • Return the index of the integer if found, else return -1.

Add your answer
Share interview questions and help millions of jobseekers 🌟

Q9. Convert Sorted Array to BST Problem Statement

Given a sorted array of length N, your task is to construct a balanced binary search tree (BST) from the array. If multiple balanced BSTs are possible, you can retu...read more

Ans.

Construct a balanced binary search tree from a sorted array.

  • Create a function that recursively constructs a balanced BST from a sorted array.

  • Ensure that the left and right subtrees of each node differ in height by no more than 1.

  • Check if the constructed tree is a valid BST by verifying the properties of a BST.

  • Return 1 if the constructed tree is correct, otherwise return 0.

Add your answer

Q10. Unique Element in Array

Given an arbitrary array arr consisting of N non-negative integers where every element appears thrice except for one. Your task is to find the element in the array that appears only once...read more

Ans.

Find the unique element in an array where every other element appears thrice.

  • Use XOR operation to find the unique element.

  • Iterate through the array and XOR each element to find the unique one.

  • Return the unique element as the answer.

Add your answer

Q11. Flip Bits Problem Explanation

Given an array of integers ARR of size N, consisting of 0s and 1s, you need to select a sub-array and flip its bits. Your task is to return the maximum count of 1s that can be obta...read more

Ans.

Given an array of 0s and 1s, find the maximum count of 1s by flipping a sub-array at most once.

  • Iterate through the array and keep track of the maximum count of 1s obtained by flipping a sub-array.

  • Consider flipping a sub-array from index i to j by changing 0s to 1s and vice versa.

  • Update the maximum count of 1s if the current count after flipping is greater.

  • Return the maximum count of 1s obtained by flipping a sub-array at most once.

Add your answer

Q12. Add Two Numbers as Linked Lists

You are given two singly linked lists, where each list represents a positive number without any leading zeros.

Your task is to add these two numbers and return the sum as a linke...read more

Ans.

Add two numbers represented as linked lists and return the sum as a linked list.

  • Traverse both linked lists simultaneously while keeping track of carry from previous sum

  • Create a new linked list to store the sum, updating the value and carry as needed

  • Handle cases where one linked list is longer than the other by adding remaining digits with carry

Add your answer

Q13. Binary Tree to Doubly Linked List

Transform a given Binary Tree into a Doubly Linked List.

Ensure that the nodes in the Doubly Linked List follow the Inorder Traversal of the Binary Tree.

Input:

The first line ...read more
Ans.

Convert a Binary Tree into a Doubly Linked List following Inorder Traversal.

  • Perform Inorder Traversal of the Binary Tree to get the nodes in order.

  • Create a Doubly Linked List by connecting the nodes in the order obtained from Inorder Traversal.

  • Return the head of the Doubly Linked List.

Add your answer

Q14. Convert a Binary Tree to its Sum Tree

Given a binary tree of integers, convert it to a sum tree where each node is replaced by the sum of the values of its left and right subtrees. Set leaf nodes to zero.

Input...read more

Ans.

Convert a binary tree to a sum tree by replacing each node with the sum of its left and right subtrees, setting leaf nodes to zero.

  • Traverse the tree in postorder fashion to calculate the sum of left and right subtrees for each node.

  • Set leaf nodes to zero and update the value of each node to the sum of its children.

  • Return the level order traversal of the modified tree.

Add your answer

Q15. Validate BST Problem Statement

Given a binary tree with N nodes, determine whether the tree is a Binary Search Tree (BST). If it is a BST, return true; otherwise, return false.

A binary search tree (BST) is a b...read more

Ans.

Validate if a given binary tree is a Binary Search Tree (BST) or not.

  • Check if the left subtree of a node contains only nodes with data less than the node's data.

  • Check if the right subtree of a node contains only nodes with data greater than the node's data.

  • Ensure that both the left and right subtrees are also binary search trees.

Add your answer

Q16. Sort an Array in Wave Form

You are given an unsorted array ARR. Your task is to sort it so that it forms a wave-like array.

Input:

The first line contains an integer 'T', the number of test cases.
For each test ...read more
Ans.

Sort an array in a wave-like pattern where each element is greater than or equal to its neighbors.

  • Iterate through the array and swap elements to form the wave pattern.

  • Start by sorting the array in non-decreasing order.

  • Then, swap adjacent elements to form the wave pattern.

  • Return the modified array as the output.

Add your answer

Q17. Binary Tree Traversals Problem Statement

Given a Binary Tree with 'N' nodes, where each node holds an integer value, your task is to compute the In-Order, Pre-Order, and Post-Order traversals of the binary tree...read more

Ans.

Implement a function to compute In-Order, Pre-Order, and Post-Order traversals of a Binary Tree given in level-order format.

  • Parse the input level-order tree elements to construct the binary tree.

  • Implement recursive functions for In-Order, Pre-Order, and Post-Order traversals.

  • Return the traversals as lists of lists for each test case.

Add your answer

Q18. Rabbit Jumping Problem

Consider 'n' carrots numbered from 1 to 'n' and 'k' rabbits. Each rabbit jumps to carrots only at multiples of its respective jumping factor Aj (i.e., Aj, 2Aj, 3Aj, ...), for all rabbits ...read more

Ans.

Calculate uneaten carrots by rabbits with specific jumping factors.

  • Iterate through each carrot and check if any rabbit jumps on it.

  • Use the jumping factors to determine which carrots are eaten.

  • Subtract the eaten carrots from the total to get the uneaten count.

Add your answer

Q19. Longest Common Subsequence Problem Statement

Given two strings STR1 and STR2, determine the length of their longest common subsequence.

A subsequence is a sequence that can be derived from another sequence by d...read more

Ans.

The task is to find the length of the longest common subsequence between two given strings.

  • Implement a function to find the longest common subsequence between two strings.

  • Use dynamic programming to solve this problem efficiently.

  • Iterate through the strings and build a matrix to store the lengths of common subsequences.

  • Return the length of the longest common subsequence found.

Add your answer

Q20. DFS Traversal Problem Statement

Given an undirected and disconnected graph G(V, E), where V is the number of vertices and E is the number of edges, the connections between vertices are provided in the 'GRAPH' m...read more

Ans.

DFS traversal to find connected components in an undirected and disconnected graph.

  • Perform DFS traversal on each vertex to find connected components

  • Maintain a visited array to keep track of visited vertices

  • Print the vertices of each connected component in ascending order

Add your answer

Q21. Maximum Frequency Number Problem Statement

Given an array of integers with numbers in random order, write a program to find and return the number which appears the most frequently in the array.

If multiple elem...read more

Ans.

Program to find the number with maximum frequency in an array of integers.

  • Create a dictionary to store the frequency of each number in the array.

  • Iterate through the array and update the frequency count in the dictionary.

  • Find the number with the maximum frequency in the dictionary and return it.

  • If multiple elements have the same maximum frequency, return the one with the lowest index.

Add your answer

Q22. Invert a Binary Tree Problem Statement

Given a Binary Tree and one of its leaf nodes, invert the binary tree by following these guidelines:

• The given leaf node becomes the root after the inversion. • For a no...read more
Ans.

Invert a binary tree based on a given leaf node as the root.

  • Start by finding the leaf node in the binary tree.

  • Move the left child of the leaf node to the right side of the leaf node.

  • Make the parent of the leaf node the left child of the leaf node.

  • Repeat the process for each test case.

  • Return the inverted binary tree in level order format.

Add your answer
Q23. ...read more

Rearrange Array to Form Largest Number

Given an array ARR consisting of non-negative integers, rearrange the numbers to form the largest possible number. The digits within each number cannot be changed.

Input:

Ans.

Rearrange the array elements to form the largest possible number by concatenating them.

  • Sort the array elements in a custom way where the concatenation of two numbers results in a larger number.

  • Use a custom comparator function while sorting the array elements.

  • Convert the sorted array elements to a single string to get the largest possible number.

Add your answer

Q24. Delete N Nodes After M Nodes in a Linked List

Given a singly linked list and two integers 'N' and 'M', traverse the linked list to retain 'M' nodes and then delete the next 'N' nodes. Continue this process unti...read more

Ans.

Traverse a linked list to retain 'M' nodes and then delete the next 'N' nodes, repeating until the end of the list.

  • Create a function that takes the head of the linked list, 'N', and 'M' as input parameters.

  • Traverse the linked list, retaining 'M' nodes and deleting the next 'N' nodes in each iteration.

  • Update the pointers accordingly to skip 'N' nodes after retaining 'M' nodes.

  • Repeat this process until the end of the linked list is reached.

  • Return the modified linked list.

Add your answer

Q25. Running Median Problem

Given a stream of integers, calculate and print the median after each new integer is added to the stream.

Output only the integer part of the median.

Example:

Input:
N = 5 
Stream = [2, 3,...read more
Ans.

Calculate and print the median after each new integer is added to the stream of integers.

  • Use a min heap to store the larger half of the numbers and a max heap to store the smaller half.

  • Keep the sizes of the two heaps balanced to efficiently calculate the median.

  • When a new integer is added, adjust the heaps accordingly and calculate the median.

  • Output only the integer part of the median after each new integer is added.

Add your answer

Q26. given an array of length n and in which numbers from 1-n will be there and each number can repeat any number of times find out which repeated more number of times

Ans.

Find the most repeated number in an array of length n with numbers 1-n.

  • Create a dictionary to store the count of each number in the array

  • Iterate through the array and update the count in the dictionary

  • Find the key with the highest count in the dictionary

Add your answer
Q27. Can you explain the concept of the String pool in Java and how garbage collection functionality works?
Ans.

String pool in Java is a special memory area where String literals are stored to optimize memory usage. Garbage collection in Java is a process of reclaiming memory occupied by objects that are no longer in use.

  • String pool is a special area in Java heap memory where String literals are stored to avoid duplicate objects.

  • When a new String is created using double quotes, Java first checks the String pool to see if an identical String already exists.

  • Garbage collection in Java is ...read more

Add your answer
Q28. Can you explain the differences between one-to-one mapping and one-to-many mapping in database design, along with some basic related questions?
Ans.

One-to-one mapping involves a single relationship between two entities, while one-to-many mapping involves a single entity being related to multiple entities.

  • One-to-one mapping: each record in one table is related to only one record in another table.

  • One-to-many mapping: each record in one table can be related to multiple records in another table.

  • In one-to-one mapping, a foreign key is used to establish the relationship between the two tables.

  • In one-to-many mapping, a foreign ...read more

Add your answer

Q29. given an array of numbers in which duplicates are there and one triplicate is there. find that number

Ans.

Find the triplicate number in an array of duplicates.

  • Iterate through the array and keep track of the frequency of each number.

  • Return the number that appears three times.

  • If no number appears three times, return null.

Add your answer

Q30. given a linked list with 2 parameters m,n. Now start reversing the m nodes and leave n nodes and continue it till u reach the end

Ans.

Reverse m nodes and leave n nodes in a linked list till the end.

  • Traverse the linked list till m nodes and reverse them

  • Traverse n nodes and continue reversing m nodes

  • Repeat the above step till the end of the linked list

  • Handle edge cases like m or n being greater than the length of the linked list

Add your answer
Q31. What is the difference between a process and a thread?
Ans.

A process is an independent entity that contains its own memory space and resources, while a thread is a subset of a process that shares the same memory space and resources.

  • A process has its own memory space, while threads within a process share the same memory space.

  • Processes are independent entities, while threads are subsets of processes.

  • Processes have their own resources like file descriptors and sockets, while threads within a process share these resources.

  • Processes comm...read more

Add your answer
Q32. What are the advantages of B+ Trees in database management systems?
Ans.

B+ Trees are advantageous in database management systems due to their ability to efficiently store and retrieve data.

  • B+ Trees have a high fanout, allowing for more keys to be stored in each node, reducing the height of the tree and improving search performance.

  • B+ Trees are balanced trees, ensuring that operations like search, insertion, and deletion have a predictable time complexity of O(log n).

  • B+ Trees are optimized for range queries, as the leaf nodes are linked together i...read more

Add your answer

Q33. All the leaf nodes of tree are doubly linked,print only the leaf nodes of a tree

Ans.

Print only the leaf nodes of a doubly linked tree.

  • Traverse the tree and check if a node has no children and both left and right pointers are null.

  • If yes, then it is a leaf node and print it.

  • If no, then continue traversing the tree.

  • Use recursion to traverse the tree in a depth-first manner.

Add your answer

Q34. Where does session id is stored in php? How server identifies request has come from which client and many other related questions?

Ans.

Session ID is stored in PHP as a cookie or a query parameter.

  • Session ID can be stored as a cookie in the client's browser.

  • Session ID can also be stored as a query parameter in the URL.

  • The server identifies the client by retrieving the session ID from the cookie or query parameter.

  • The session ID is then used to retrieve the corresponding session data stored on the server.

  • The server can also use other methods like IP address or user agent to identify the client.

Add your answer

Q35. Given an array of +ve and -ve numbers , have to rearrange them ( like +ve numbers to left and -ve numbers to right of the array)

Ans.

Rearrange an array of positive and negative numbers with positive numbers on the left and negative numbers on the right.

  • Create two empty arrays, one for positive numbers and one for negative numbers

  • Loop through the original array and add positive numbers to the positive array and negative numbers to the negative array

  • Concatenate the positive and negative arrays to create the rearranged array

Add your answer
Q36. How can you synchronize a HashMap in Java?
Ans.

You can synchronize a HashMap in Java using the synchronizedMap() method from the Collections class.

  • Use synchronizedMap() method to create a synchronized HashMap: Map<String, String> syncMap = Collections.synchronizedMap(new HashMap<>());

  • Alternatively, you can use ConcurrentHashMap which is thread-safe and does not require external synchronization.

  • Ensure proper synchronization to avoid concurrent modification exceptions.

Add your answer

Q37. String pool and how garbage collection functionality works?

Ans.

String pool is a cache of string literals in memory. Garbage collection frees up memory by removing unused objects.

  • String pool is a cache of string literals in memory

  • Strings are immutable and can be shared among multiple objects

  • Garbage collection removes unused objects to free up memory

  • String objects that are no longer referenced are eligible for garbage collection

Add your answer

Q38. Find 2 elements in array whose sum is equal to given number?

Ans.

The question asks to find two elements in an array whose sum is equal to a given number.

  • Iterate through the array and for each element, check if the difference between the given number and the current element exists in the array.

  • Use a hash set to store the elements as you iterate through the array for efficient lookup.

  • Return the pair of elements if found, otherwise return a message indicating no such pair exists.

Add your answer

Q39. Change Binary tree so that parent node is the sum of root nodes

Ans.

Change binary tree to make parent node the sum of root nodes

  • Traverse the tree in post-order

  • For each node, update its value to the sum of its children

  • Return the updated root node

Add your answer

Q40. Build a bst out of the unsorted array by looping over the array and inserting each element to the tree?

Ans.

Yes

  • Create an empty binary search tree (BST)

  • Loop over the unsorted array

  • For each element, insert it into the BST using the appropriate insertion logic

  • Repeat until all elements are inserted

  • The resulting BST will be built from the unsorted array

Add your answer

Q41. explain all the serach algorithm you know with space and Time complexities

Ans.

Explanation of search algorithms with their space and time complexities.

  • Linear Search - O(n) time complexity, O(1) space complexity

  • Binary Search - O(log n) time complexity, O(1) space complexity

  • Jump Search - O(√n) time complexity, O(1) space complexity

  • Interpolation Search - O(log log n) time complexity, O(1) space complexity

  • Exponential Search - O(log n) time complexity, O(1) space complexity

  • Fibonacci Search - O(log n) time complexity, O(1) space complexity

Add your answer
Q42. What is indexing in the context of databases?
Ans.

Indexing in databases is a technique used to improve the speed of data retrieval by creating a data structure that allows for quick lookups.

  • Indexes are created on columns in a database table to speed up the retrieval of rows that match a certain condition.

  • They work similar to the index in a book, allowing the database to quickly find the relevant data without having to scan the entire table.

  • Examples of indexes include primary keys, unique keys, and composite indexes.

  • Indexes c...read more

Add your answer

Q43. Inorder Travesal of a tree without recursion(write the code)

Ans.

Inorder traversal of a tree without recursion

  • Create an empty stack and initialize current node as root

  • Push the current node to stack and set current = current.left until current is NULL

  • If current is NULL and stack is not empty, pop the top item from stack, print it and set current = popped_item.right

  • Repeat step 2 and 3 until stack is empty

Add your answer

Q44. Indexing in mysql? How many types of indexing in mysql?

Ans.

Indexing in MySQL improves query performance. There are several types of indexing in MySQL.

  • Indexes are used to quickly locate data without scanning the entire table.

  • Types of indexing in MySQL include B-tree, hash, full-text, and spatial indexes.

  • B-tree indexes are the most common and suitable for most use cases.

  • Hash indexes are used for exact match lookups.

  • Full-text indexes are used for searching text-based data efficiently.

  • Spatial indexes are used for optimizing spatial queri...read more

Add your answer

Q45. What is the difference between get and post?

Ans.

GET is used to retrieve data from a server, while POST is used to send data to a server.

  • GET requests are idempotent, meaning they can be repeated without changing the result

  • POST requests are not idempotent and can have side effects on the server

  • GET requests can be cached by the browser, while POST requests cannot

  • GET requests have limitations on the amount of data that can be sent, while POST requests have no limitations

  • GET requests should not be used for sensitive data, as th...read more

Add your answer

Q46. Process vs Thread differences and synchronization,deadlock examples?

Ans.

Process vs Thread differences and synchronization, deadlock examples

  • Process is an instance of a program while thread is a subset of a process

  • Processes are independent while threads share the same memory space

  • Synchronization is used to coordinate access to shared resources

  • Deadlock occurs when two or more threads are blocked waiting for each other to release resources

  • Examples of synchronization include mutex, semaphore, and monitor

  • Examples of deadlock include dining philosopher...read more

Add your answer

Q47. Can trigger be used with select statement?

Ans.

Yes, triggers can be used with select statements in SQL.

  • Triggers are database objects that are automatically executed in response to certain events, such as insert, update, or delete operations.

  • While triggers are commonly used with insert, update, and delete statements, they can also be used with select statements.

  • Using triggers with select statements allows you to perform additional actions or validations before or after the select operation.

  • For example, you can use a trigge...read more

Add your answer

Q48. LRU page Replacement Algorithm for large data

Ans.

LRU page replacement algorithm is used to replace the least recently used page in memory with a new page.

  • LRU stands for Least Recently Used

  • It is a cache eviction algorithm

  • It is used to manage memory in operating systems

  • It works by keeping track of the pages that are used recently and the ones that are not

  • When a new page is to be loaded into memory, the algorithm checks which page has not been used for the longest time and replaces it with the new page

Add your answer

Q49. Can constructor be declared as private?

Ans.

Yes, a constructor can be declared as private.

  • Declaring a constructor as private restricts its accessibility to only the class itself.

  • This can be useful in scenarios where you want to control the creation of objects of that class.

  • Private constructors are commonly used in singleton design pattern implementations.

  • Example: private constructor in a singleton class:

  • class Singleton { private Singleton() {} }

Add your answer

Q50. Given a string of paranthesis tell longest valid parantheisis

Ans.

Use stack to keep track of indices of opening parentheses, update max length when closing parentheses found

  • Use a stack to keep track of indices of opening parentheses

  • When a closing parentheses is found, update max length by calculating the difference between current index and top of stack

  • Handle edge cases like extra closing parentheses or unmatched opening parentheses

  • Example: Input: "(()()", Output: 4 (for "()()")

Add your answer

Q51. Cookie in php? Size of the cookie, expiry etc?

Ans.

A cookie in PHP is a small piece of data stored on the client's computer. It has a size limit and an expiry date.

  • A cookie is used to store information on the client's computer for future use.

  • In PHP, cookies are set using the setcookie() function.

  • The size of a cookie is limited to 4KB.

  • Cookies can have an expiry date, after which they are no longer valid.

  • The expiry date can be set using the 'expires' parameter in the setcookie() function.

  • If no expiry date is set, the cookie wil...read more

Add your answer

Q52. Given a string find longest palindromeic substring

Ans.

Find the longest palindromic substring in a given string.

  • Use dynamic programming to check for palindromes within the string.

  • Start by checking for palindromes of length 1 and 2, then expand to longer substrings.

  • Keep track of the longest palindrome found so far.

Add your answer

Q53. Can a constructor be private?

Ans.

Yes, a constructor can be private.

  • A private constructor can only be accessed within the class itself.

  • It is often used in singleton design pattern to restrict object creation.

  • Private constructors are also useful for utility classes that only contain static methods.

Add your answer

Q54. What is session in php?

Ans.

Session in PHP is a way to store and retrieve data for a user across multiple requests.

  • Sessions are used to maintain user-specific data on the server side.

  • A session is created for each user and is identified by a unique session ID.

  • Session data can be stored in server files or in a database.

  • Session variables can be accessed and modified throughout the user's session.

  • Sessions can be used to implement features like user authentication and shopping carts.

Add your answer

Q55. How many types of trigger?

Ans.

There are two types of triggers: DML triggers and DDL triggers.

  • DML triggers are fired in response to DML (Data Manipulation Language) statements like INSERT, UPDATE, DELETE.

  • DDL triggers are fired in response to DDL (Data Definition Language) statements like CREATE, ALTER, DROP.

  • Examples: A DML trigger can be used to log changes made to a table, while a DDL trigger can be used to enforce certain rules when a table is altered.

Add your answer

Q56. Inorder Traversal of a tree

Ans.

Inorder traversal is a way of visiting all nodes in a binary tree by visiting the left subtree, then the root, and then the right subtree.

  • Start at the root node

  • Traverse the left subtree recursively

  • Visit the root node

  • Traverse the right subtree recursively

  • Repeat until all nodes have been visited

Add your answer

Q57. PreOrder traversal without recursion?

Ans.

PreOrder traversal without recursion is done using a stack to simulate the function call stack.

  • Create an empty stack and push the root node onto it.

  • While the stack is not empty, pop a node from the stack and process it.

  • Push the right child of the popped node onto the stack if it exists.

  • Push the left child of the popped node onto the stack if it exists.

Add your answer

Q58. Reverse a linkedlist ?

Ans.

Reverse a linkedlist by changing the direction of pointers.

  • Iterate through the linkedlist and change the direction of pointers.

  • Keep track of previous, current and next nodes.

  • Set the next pointer of current node to previous node.

  • Move to next node and repeat until end of list is reached.

Add your answer

Q59. Linked List in a binary tree

Ans.

A linked list can be implemented in a binary tree by using the left child as the next node and the right child as the previous node.

  • Each node in the binary tree will have a left child pointer and a right child pointer.

  • Traversal of the linked list can be done by following the left child pointers.

  • Example: In a binary tree, the left child of a node can point to the next node in the linked list.

Add your answer

Q60. 3 sum Trapping rain water

Ans.

3 sum and trapping rain water are common coding interview questions that test problem-solving skills.

  • 3 sum problem involves finding three numbers in an array that add up to a target sum.

  • Trapping rain water problem involves calculating the amount of water that can be trapped between bars in an elevation map.

  • Both problems require efficient algorithms to solve.

Add your answer

Q61. Engines in mysql?

Ans.

Engines in MySQL are the underlying software components that handle storage, indexing, and querying of data.

  • MySQL supports multiple storage engines, each with its own strengths and features.

  • Some commonly used engines in MySQL are InnoDB, MyISAM, and Memory.

  • InnoDB is the default engine in MySQL and provides support for transactions and foreign keys.

  • MyISAM is known for its simplicity and speed but lacks transaction support.

  • Memory engine stores data in memory for faster access b...read more

Add your answer

Q62. Triggers in mysql?

Ans.

Triggers in MySQL are database objects that are automatically executed in response to specified events.

  • Triggers are used to enforce business rules, maintain data integrity, and automate tasks.

  • They can be defined to execute before or after an INSERT, UPDATE, or DELETE operation.

  • Triggers can be written in SQL or in a programming language like PL/SQL.

  • Examples of trigger events include inserting a new record, updating a record, or deleting a record.

  • Triggers can be used to perform...read more

Add your answer

Q63. Indexing in mysql?

Ans.

Indexing in MySQL improves the performance of database queries by creating a data structure that allows for faster data retrieval.

  • Indexes are created on one or more columns of a table.

  • They help in speeding up the search, sorting, and joining of data.

  • Indexes can be created using the CREATE INDEX statement.

  • Common types of indexes include B-tree, hash, and full-text indexes.

  • Indexes should be used judiciously as they consume disk space and require additional maintenance.

Add your answer

Q64. implement LRU cache

Ans.

LRU cache is a data structure that stores the most recently used items, discarding the least recently used items when full.

  • Use a combination of a doubly linked list and a hashmap to efficiently implement LRU cache.

  • When an item is accessed, move it to the front of the linked list to mark it as the most recently used.

  • When adding a new item, check if the cache is full. If so, remove the least recently used item from the end of the linked list and hashmap.

  • Keep track of the size o...read more

Add your answer

Q65. right view of a Tree

Ans.

The right view of a tree shows the nodes that are visible when looking at the tree from the right side.

  • The right view of a tree can be obtained by performing a level order traversal and keeping track of the rightmost node at each level.

  • Example: For a tree with nodes 1, 2, 3, 4, 5, the right view would be 1, 3, 5.

Add your answer
Contribute & help others!
Write a review
Share interview
Contribute salary
Add office photos

Interview Process at Meesho

based on 7 interviews
2 Interview rounds
Coding Test Round
Video Call Round
View more
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top Software Developer Interview Questions from Similar Companies

3.4
 • 16 Interview Questions
3.8
 • 16 Interview Questions
4.3
 • 15 Interview Questions
3.4
 • 13 Interview Questions
3.5
 • 10 Interview Questions
View all
Share an Interview
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
70 Lakh+

Reviews

5 Lakh+

Interviews

4 Crore+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter