Find Interview Questions for Top Companies
Ques:- You are given a function printMostFrequentWords which takes in an array of strings. You are required to print a list of all the letters that occurred with the highest frequency in each line of the array, followed by the frequency. The list o…
Asked In :-
Right Answer:
```python
def printMostFrequentWords(lines):
for line in lines:
frequency = {}
for char in line:
if char.isalpha(): # Consider only letters
frequency[char] = frequency.get(char, 0) + 1

max_freq = max(frequency.values(), default=0)
most_frequent = [char for char, freq in frequency.items() if freq == max_freq]

print(f"{', '.join(most_frequent)}: {max_freq}")

# Example usage:
lines = ["hello world", "test case", "frequency analysis"]
printMostFrequentWords(lines)
```
Ques:- Write code for minimal spanning tree
Asked In :-
Right Answer:
```python
import heapq

def minimal_spanning_tree(graph):
mst = []
visited = set()
min_heap = [(0, 0)] # (cost, vertex)

while min_heap:
cost, u = heapq.heappop(min_heap)
if u not in visited:
visited.add(u)
mst.append((cost, u))
for v, weight in graph[u]:
if v not in visited:
heapq.heappush(min_heap, (weight, v))

return mst[1:] # Exclude the initial dummy node

# Example graph represented as an adjacency list
graph = {
0: [(1, 4), (2, 1)],
1: [(0, 4), (2, 2), (3, 5)],
2: [(0, 1), (1, 2), (3, 8)],
3: [(
Ques:- What is the best way to find k largest elements in an unsorted array? and what is it's time complexity?
Asked In :-
Right Answer:
The best way to find the k largest elements in an unsorted array is to use a min-heap of size k. Insert elements into the heap, and if the heap exceeds size k, remove the smallest element. This ensures that the heap contains the k largest elements.

The time complexity of this approach is O(n log k), where n is the number of elements in the array.
Ques:- There are n different machines, each having n numbers. Find median of these n*n numbers, but you can load only 2n integers at a time in memory
Asked In :-
Right Answer:
To find the median of n*n numbers from n different machines while loading only 2n integers at a time, you can use the following approach:

1. **Merge and Sort**: Use a min-heap (or max-heap) to merge the numbers from the machines. Load 2n numbers into memory, sort them, and keep track of the median.

2. **Iterate**: Repeat the process by loading the next set of 2n numbers from the machines, maintaining the sorted order.

3. **Find Median**: After processing all numbers, if n*n is odd, the median is the middle element. If even, it is the average of the two middle elements.

This approach efficiently manages memory constraints while ensuring you can find the median.
Ques:- Explain Fibonacci search and compare it with Bianry search
Asked In :-
Right Answer:
Fibonacci search is a search algorithm that uses Fibonacci numbers to divide the array into smaller sections, allowing it to find an element in a sorted array. It works by comparing the target value to elements at positions determined by Fibonacci numbers, effectively narrowing down the search range.

Comparison with Binary Search:
- **Efficiency**: Both have a time complexity of O(log n), but Fibonacci search can be more efficient in certain scenarios, especially with large datasets.
- **Division Method**: Binary search divides the array into two halves, while Fibonacci search divides it into sections based on Fibonacci numbers.
- **Memory Usage**: Fibonacci search can be more memory efficient as it does not require additional space for recursion like some binary search implementations.
- **Data Structure**: Fibonacci search is more suited for data structures where division into halves is not optimal, while binary search is straightforward and widely used.
Ques:- Given a Binary Tree and its depth d find the number of leaf nodes in that tree.
Asked In :-
Right Answer:
To find the number of leaf nodes in a binary tree of depth d, the formula is (2^d).
Ques:- A sorting algorithm which can prove to be a best time algorithm in one case and a worst time algorithm in worst case is
Asked In :-
Right Answer:
QuickSort
Ques:- You are given a string which contains some special characters. You also have set of special characters. You are given other string (call it as pattern string). Your job is to write a program to replace each special characters in given string by pa…
Asked In :-
Right Answer:
```python
def replace_special_characters(input_string, special_chars, pattern_string):
for char in special_chars:
input_string = input_string.replace(char, pattern_string)
return input_string

# Example usage
input_string = "Hello @world! #2023"
special_chars = "@#!"
pattern_string = "*"
result = replace_special_characters(input_string, special_chars, pattern_string)
print(result) # Output: "Hello *world* *2023"
```
Ques:- Input is a NxN matrix which contains only 0's and 1's. The condition is no 1 will occur in a row after 0. Find the index of the row which contains maximum number of zeros. Example: lets say 5×5 matrix 1 0 0 0 0 1 1 0 0 0 1 …
Asked In :-
Right Answer:
To find the index of the row with the maximum number of zeros in a NxN matrix where no 1 occurs after a 0 in any row, you can iterate through each row, count the zeros, and keep track of the maximum count and its corresponding row index.

Here’s a simple algorithm:

1. Initialize `max_zeros` to -1 and `max_row_index` to -1.
2. For each row `i` from 0 to N-1:
- Count the number of zeros in the row.
- If the count of zeros is greater than `max_zeros`, update `max_zeros` and set `max_row_index` to `i`.
3. Return `max_row_index`.

This will give you the index of the row with the maximum number of zeros.
Ques:- Square root of a perfect square in O(Logn) complexity
Asked In :-
Right Answer:
To find the square root of a perfect square in O(Log n) complexity, you can use a binary search algorithm. Here's a simple implementation in Python:

```python
def square_root(n):
if n < 0:
return None # Square root of negative number is not defined
left, right = 0, n
while left <= right:
mid = (left + right) // 2
if mid * mid == n:
return mid
elif mid * mid < n:
left = mid + 1
else:
right = mid - 1
return right # right will be the integer square root of n
```

This function efficiently finds the integer square root of a perfect square in O(Log n) time.
Ques:- An array of size n has numbers from 1 to n. One number is missing and one number occurs twice. Find these two numbers
Asked In :-
Right Answer:
To find the missing number and the duplicate number in an array of size n containing numbers from 1 to n:

1. Calculate the expected sum of numbers from 1 to n using the formula: `expected_sum = n * (n + 1) / 2`.
2. Calculate the actual sum of the array elements: `actual_sum = sum(array)`.
3. Calculate the expected sum of squares: `expected_sum_squares = n * (n + 1) * (2n + 1) / 6`.
4. Calculate the actual sum of squares of the array elements: `actual_sum_squares = sum(x^2 for x in array)`.
5. Let the missing number be `x` and the duplicate number be `y`. You can set up the following equations:
- `x - y = expected_sum - actual_sum` (Equation 1)
- `x^2 - y^2 = expected_sum_squares - actual
Ques:- How do you implement the dynamic memory allocation using heap
Asked In :-
Right Answer:
To implement dynamic memory allocation using the heap in programming, you can use functions like `malloc()`, `calloc()`, or `realloc()` in C/C++. For example:

```c
#include <stdlib.h>

int *arr = (int *)malloc(size * sizeof(int)); // Allocates memory
if (arr == NULL) {
// Handle allocation failure
}

// Use the allocated memory

free(arr); // Deallocates memory when done
```
Ques:- Given 3 arrays, pick 3 nos, one from each array, say a,b,c such that |a-b|+|b-c|+|c-a| is minimum.
Asked In :-
Right Answer:
To minimize |a-b| + |b-c| + |c-a|, sort the three arrays and use a three-pointer technique to find the optimal combination of a, b, and c. Iterate through the arrays, adjusting pointers to minimize the expression until you find the minimum value.
Ques:- Generate n random numbers in the range 0…n-1 without repetition (using something like drand48 which returns a fraction in the range [0…1).
Asked In :-
Right Answer:
To generate `n` random numbers in the range `0` to `n-1` without repetition, you can use the following approach:

1. Create an array of integers from `0` to `n-1`.
2. Shuffle the array using a random shuffle algorithm (like Fisher-Yates).
3. The shuffled array will contain `n` unique random numbers in the desired range.

Here’s a simple implementation in Python:

```python
import random

def generate_unique_random_numbers(n):
numbers = list(range(n))
random.shuffle(numbers)
return numbers

# Example usage:
n = 10
random_numbers = generate_unique_random_numbers(n)
print(random_numbers)
```
Ques:- Given an array of integers, each element represents the max number of jumps can make forward. What is the minimum number of element selections to reach the end of the array (starting from the first element). Example: arr = 1, 3, 5, 8, 9, 2, …
Asked In :-
Right Answer:
To solve the problem, you can use a greedy algorithm. Start from the first element and keep track of the farthest point you can reach. Incrementally select the next jump based on the maximum reach from the current position. The minimum number of jumps required to reach the end of the array is 3 for the example array [1, 3, 5, 8, 9, 2].
Ques:- Given an array, sort the array in such a way that the first part of the sorted array contains odd numbers, and the second part contains even numbers. The first part has to be sorted in descending order and the second part in ascending order. Not e…
Asked In :-
Right Answer:
To sort the array as specified, you can follow these steps:

1. Separate the odd and even numbers into two different lists.
2. Sort the list of odd numbers in descending order.
3. Sort the list of even numbers in ascending order.
4. Concatenate the two lists, with the sorted odd numbers first followed by the sorted even numbers.

Here is a sample implementation in Python:

```python
def sort_array(arr):
odds = sorted([x for x in arr if x % 2 != 0], reverse=True)
evens = sorted([x for x in arr if x % 2 == 0])
return odds + evens

# Example usage
array = [5, 3, 2, 8, 1, 4]
sorted_array = sort_array(array)
print(sorted_array) # Output: [5, 3, 1, 2, 4, 8]
```
Ques:- An algorithm to print all the 10-digit nos such that first 1 digit is divisible by 1, first 2 digits by 2, first 3 digits by 3 and so on…first 9 digits by 9. I think the tenth digit can be anything from 0 to 9.
Asked In :-
Right Answer:
To find all 10-digit numbers where the first digit is divisible by 1, the first two digits by 2, the first three digits by 3, and so on up to the first nine digits by 9, you can use the following algorithm:

1. Loop through all 10-digit numbers from 1000000000 to 9999999999.
2. For each number, convert it to a string to easily access individual digits.
3. Check the divisibility conditions:
- If the integer formed by the first digit is divisible by 1.
- If the integer formed by the first two digits is divisible by 2.
- If the integer formed by the first three digits is divisible by 3.
- Continue this up to the first nine digits being divisible by 9.
4. If all conditions are satisfied, print the number.

Here is a simple pseudocode representation:

```plaintext
for num from 1000000000 to 999
Ques:- You are given an array of integers. You have to output the largest range so that all numbers in the range are present in the array. The numbers might be present in any order. Have to do it in linear time. May use extra memory. But Hashing is not t…
Asked In :-
Right Answer:
To find the largest range in an array of integers in linear time without using hashing, you can follow these steps:

1. **Sort the Array**: First, sort the array. This will take O(n log n) time.
2. **Find the Largest Range**: Iterate through the sorted array and keep track of the current range. Whenever you find consecutive numbers, extend the range. If you find a gap, compare the current range with the largest range found so far and update if necessary.

However, since the question specifies linear time, you can achieve this by using a different approach:

1. **Use a Set**: Store all elements of the array in a set for O(1) average time complexity for lookups.
2. **Iterate through the Array**: For each number, check if it is the start of a new range (i.e., check if the number - 1 is not in the set).
3. **Expand the Range**: If it
Ques:- We have N element array with k distinct keys(No relation between k & N given so assume (k<N). What is the best method to sort this array without using any extra memory? Please elaborate.
Asked In :-
Right Answer:
The best method to sort an array with N elements and k distinct keys without using any extra memory is to use the **Counting Sort** algorithm. Since k is much smaller than N, you can create a count array of size k to count the occurrences of each key. Then, you can overwrite the original array with the sorted elements based on the counts. This approach sorts the array in O(N) time while using O(k) space for the count array, which is acceptable as it does not count as extra memory in the context of the original array.
Ques:- Given an unsorted array of numbers. Find if the array consists of consecutive numbers after sorting. Do this in linear time.
Asked In :-
Right Answer:
To determine if an unsorted array consists of consecutive numbers in linear time, follow these steps:

1. Find the minimum and maximum values in the array.
2. Check if the range (max - min + 1) is equal to the length of the array.
3. Use a hash set to track the unique numbers in the array.
4. Ensure that the size of the hash set is equal to the length of the array.

If all conditions are met, the array consists of consecutive numbers.

Here’s a sample implementation in Python:

```python
def are_consecutive(arr):
if len(arr) < 2:
return True

min_val = min(arr)
max_val = max(arr)

if max_val - min_val + 1 != len(arr):
return False

num_set = set(arr)

return len(num_set) == len(arr)

# Example usage
arr = [3, 2, 1, 4,


The Project Leader / Project Manager category on takluu.com is tailored for professionals aspiring to manage and lead projects efficiently across industries. Whether you are stepping into your first managerial role or aiming for senior project leadership positions, this section equips you with the knowledge and interview readiness required to excel.

Project management is about much more than just scheduling tasks. It involves defining clear objectives, resource planning, risk assessment, stakeholder communication, quality control, and team motivation. Our curated content covers key project management methodologies like Waterfall, Agile, Scrum, and Kanban, along with essential tools such as MS Project, Jira, and Trello.

You will find detailed explanations of core concepts including scope management, time and cost estimation, risk management, conflict resolution, and performance monitoring. Real-world interview questions and scenario-based problems help you demonstrate your leadership skills and decision-making ability during interviews.

The section also highlights soft skills such as effective communication, negotiation, and team building — crucial traits for successful project leaders and managers. Additionally, we cover PMP certification topics and best practices aligned with industry standards.

Whether the interview focuses on technical project management or behavioral competencies, this category prepares you to answer with clarity and confidence.

At Takluu, we aim to transform your project management knowledge into practical skills and interview success. Start preparing today and lead your projects — and career — to new heights.

AmbitionBox Logo

What makes Takluu valuable for interview preparation?

1 Lakh+
Companies
6 Lakh+
Interview Questions
50K+
Job Profiles
20K+
Users