Intuit
10+ Welspun Corp Interview Questions and Answers
Q1. Grid Satisfaction Problem
In this problem, you are given a grid of size N*M containing two types of people: type ‘A’ and type ‘B’. You are given the number of people of each type: 'countA' denotes the number of...read more
Given a grid with type A and B people, maximize satisfaction based on neighbors.
Start with type A people for maximum satisfaction
Optimally place people to maximize satisfaction
Consider satisfaction levels for each type of person and their neighbors
Q2. Problem Statement: Find the Number of States
You are given ‘n’ cities, some of which are connected by bidirectional roads. You also have an ‘n x n’ matrix ‘roads’, where if city ‘i’ and city ‘j’ are connected b...read more
Find the number of states of cities connected by roads in a matrix.
Identify connected cities using DFS or Union-Find algorithm
Count the number of disjoint sets to determine the number of states
Handle self-connections of cities by setting roads[i][i] = 1
Q3. Binary Tree Diameter Problem Statement
You are given a Binary Tree, and you need to determine the length of the diameter of the tree.
The diameter of a binary tree is the length of the longest path between any ...read more
The task is to find the diameter of a binary tree, which is the longest path between any two nodes in the tree.
Traverse the tree to find the longest path between two nodes.
Keep track of the maximum diameter found during traversal.
The diameter may or may not pass through the root node.
Consider the height of the left and right subtrees to calculate the diameter.
Q4. Triplets with Given Sum Problem
Given an array or list ARR
consisting of N
integers, your task is to identify all distinct triplets within the array that sum up to a specified number K
.
Explanation:
A triplet i...read more
Identify all distinct triplets within an array that sum up to a specified number.
Iterate through the array and use nested loops to find all possible triplets.
Use a set to store unique triplets and check if the sum equals the target.
Handle edge cases like duplicate elements and no valid triplets.
Return the triplets as space-separated integers or -1 if no triplets exist.
Q5. Number of Islands Problem Statement
You are provided with a 2-dimensional matrix having N
rows and M
columns, containing only 1s (land) and 0s (water). Your goal is to determine the number of islands in this ma...read more
Count the number of islands in a 2D matrix of 1s and 0s.
Use Depth First Search (DFS) or Breadth First Search (BFS) to traverse the matrix and identify connected groups of 1s.
Maintain a visited array to keep track of visited cells to avoid redundant traversal.
Increment the island count each time a new island is encountered.
Consider edge cases like boundary conditions and handling of diagonals while traversing.
Handle the input matrix efficiently to optimize the solution.
Example...read more
Q6. Longest Palindromic Substring Problem Statement
You are provided with a string STR
of length N
. The goal is to identify the longest palindromic substring within this string. In cases where multiple palindromic ...read more
Given a string, find the longest palindromic substring, prioritizing the one with the smallest start index.
Iterate through the string and expand around each character to find palindromes
Keep track of the longest palindrome found and its starting index
Return the longest palindromic substring with the smallest start index
Q7. Max Game Minimum Penalty Problem
In this game, you are given a collection of 'N' numbers. The objective is to minimize the total penalty incurred while playing by following these steps:
- Select any two numbers,...read more
The objective is to minimize total penalty by selecting two numbers, summing them, and accumulating the penalty until only one number remains.
Iteratively select two numbers, sum them, and accumulate the penalty until only one number remains.
Choose the two smallest numbers to minimize the penalty.
Repeat the process until only one number remains to find the minimum possible penalty.
Q8. Stack using Two Queues Problem Statement
Develop a Stack Data Structure to store integer values using two Queues internally.
Your stack implementation should provide these public functions:
Explanation:
1. Cons...read more
Implement a stack using two queues to store integer values.
Use two queues to simulate stack operations efficiently.
Maintain the top element in one of the queues for easy access.
Ensure proper handling of edge cases like empty stack.
Example: Push elements onto one queue, then dequeue and enqueue to the other queue for pop operation.
Example: Use a flag to track the top element and update it accordingly.
Use sliding window technique to find smallest subarray with k distinct values.
Use a sliding window approach to keep track of the subarray with k distinct values.
Use a hashmap to store the frequency of each element in the window.
Slide the window to the right until the hashmap contains k distinct elements.
Shrink the window from the left while maintaining k distinct elements.
Update the minimum subarray length as you slide the window.
Return the smallest subarray length found.
Exam...read more
Q10. Kth Largest Element Problem
Given an array containing N
distinct positive integers and a number K
, determine the Kth largest element in the array.
Example:
Input:
N = 6, K = 3, array = [2, 1, 5, 6, 3, 8]
Output...read more
Find the Kth largest element in an array of distinct positive integers.
Sort the array in non-increasing order and return the Kth element.
Use a priority queue or quick select algorithm for efficient solution.
Handle constraints like array size and element values properly.
Ensure all elements in the array are distinct for accurate results.
Q11. Rearrange Linked List Problem Statement
Given a singly linked list in the form 'L1' -> 'L2' -> 'L3' -> ... 'Ln', your task is to rearrange the nodes to the form 'L1' -> 'Ln' -> 'L2' -> 'Ln-1', etc. You must not...read more
Rearrange the nodes of a singly linked list in a specific order without altering the data of the nodes.
Use two pointers to split the linked list into two halves, reverse the second half, and then merge the two halves alternately.
Ensure to handle cases where the number of nodes is odd or even separately.
Time complexity: O(N), Space complexity: O(1)
Example: Input: 1 -> 2 -> 3 -> 4 -> 5 -> NULL, Output: 1 -> 5 -> 2 -> 4 -> 3 -> NULL
Q12. What is polymorphism?
Polymorphism is the ability of a function or method to behave differently based on the object it is acting upon.
Polymorphism allows objects of different classes to be treated as objects of a common superclass.
There are two types of polymorphism: compile-time (method overloading) and runtime (method overriding).
Example: Inheritance allows a child class to override a method from its parent class, exhibiting polymorphic behavior.
More about working at Intuit
Interview Process at Welspun Corp
Top Software Developer Intern Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month