Find Interview Questions for Top Companies
Ques:- You are given n ropes,maybe of different length. the cost of tying two ropes is the sum of their lengths.Find a way to tie these ropes together so that the cost is minimum.
Asked In :- smsc,
Right Answer:
Use a min-heap (priority queue) to repeatedly tie the two shortest ropes together. The cost of tying them is added to a total cost variable. After tying, push the new rope back into the heap. Repeat until only one rope remains. The total cost will be the minimum cost to tie all ropes together.
Ques:- Given a binary matrix, find out the maximum size rectangular sub-matrix with all 1
Asked In :-
Right Answer:
To find the maximum size rectangular sub-matrix with all 1s in a binary matrix, you can use a dynamic programming approach. Here's a concise algorithm:

1. Create a 2D array `heights` of the same dimensions as the binary matrix to store the height of consecutive 1s for each column.
2. Iterate through each cell in the binary matrix:
- If the cell is 1, update `heights[i][j]` to `heights[i-1][j] + 1`. If it's 0, set `heights[i][j]` to 0.
3. For each row in `heights`, treat it as a histogram and calculate the maximum rectangle area using a stack-based approach:
- For each height, maintain a stack to find the width of the rectangle that can be formed with that height.
4. Keep track of the maximum area found during the iterations.

The maximum area found will correspond to the dimensions of
Ques:- Let's say you have a phrase without any spaces – eg. “thisisawesome”. Given a dictionary, how would you add spaces in this string?
Asked In :-
Right Answer:
You can solve this problem using dynamic programming. Here's a concise approach:

1. Create a set from the dictionary for O(1) lookups.
2. Use a dynamic programming array `dp` where `dp[i]` stores the best way to segment the substring from the start to the i-th character.
3. Initialize `dp[0]` as an empty string (base case).
4. For each index `i` from 1 to the length of the phrase:
- Check all possible previous indices `j` (from 0 to i) to see if the substring `phrase[j:i]` is in the dictionary.
- If it is, update `dp[i]` to `dp[j] + " " + phrase[j:i]` if this results in a valid segmentation.
5. The final result will be in `dp[length of phrase]`.

This will give you the segmented phrase with spaces added.
Ques:- Find all combinations of telephone#
Asked In :-
Right Answer:
To find all combinations of a telephone number where each digit corresponds to letters on a phone keypad, you can use a backtracking algorithm. Here’s a simple approach in Python:

```python
def letter_combinations(digits):
if not digits:
return []

phone_map = {
'2': 'abc', '3': 'def', '4': 'ghi', '5': 'jkl',
'6': 'mno', '7': 'pqrs', '8': 'tuv', '9': 'wxyz'
}

def backtrack(index, path):
if index == len(digits):
combinations.append("".join(path))
return
possible_letters = phone_map[digits[index]]
for letter in possible_letters:
path.append(letter)
backtrack(index + 1, path)
path.pop()

combinations = []
backtrack(0, [])
return combinations

# Example usage:
Ques:- Given an expression remove the unnecessary brackets in it with out creating an ambiguity in its execution.
Asked In :-
Right Answer:
To remove unnecessary brackets from an expression without creating ambiguity, follow these steps:

1. **Identify Redundant Brackets**: Check if a pair of brackets can be removed without changing the meaning of the expression. For example, in `((a + b))`, the outer brackets are unnecessary.

2. **Check Operator Precedence**: Ensure that removing brackets does not alter the order of operations. For instance, in `a * (b + c)`, removing the brackets would change the expression to `a * b + c`, which is incorrect.

3. **Use a Stack**: Traverse the expression character by character. Use a stack to keep track of opening brackets. When you encounter a closing bracket, check the top of the stack:
- If the top is an opening bracket that does not affect the operation (like `()` around a single variable), pop it and discard.
- If it contains operators or multiple variables, keep the brackets.

4. **Rebuild the
Ques:- You are given a dictionary of all valid words. You have the following 3 operations permitted on a word: 1) delete a character 2) insert a character. 3) replace a character.
Asked In :-
Right Answer:
To determine if a word can be transformed into another valid word using the allowed operations (delete, insert, replace), you can use the following approach:

1. **Check Length Difference**: Calculate the length difference between the two words. If the difference is more than 1, return false.

2. **Count Operations**:
- If the lengths are the same, check how many characters differ. If there is exactly one character difference, return true (replace operation).
- If the first word is longer by one character, check if removing one character from the longer word can match the shorter word (delete operation).
- If the second word is longer by one character, check if inserting one character into the shorter word can match the longer word (insert operation).

3. **Return Result**: If any of the above conditions are satisfied, return true; otherwise, return false.
Ques:- Given a NXN array, rotate the array 90 degrees counter-clockwise in place.
Asked In :- secure meters,
Right Answer:
To rotate an NXN array 90 degrees counter-clockwise in place, follow these steps:

1. Transpose the matrix: Swap elements at positions (i, j) and (j, i) for all i < j.
2. Reverse each row: For each row, reverse the order of elements.

Here’s the code in Python:

```python
def rotate_counter_clockwise(matrix):
n = len(matrix)

# Step 1: Transpose the matrix
for i in range(n):
for j in range(i + 1, n):
matrix[i][j], matrix[j][i] = matrix[j][i], matrix[i][j]

# Step 2: Reverse each row
for i in range(n):
matrix[i].reverse()
```

This will rotate the matrix 90 degrees counter-clockwise in place.
Ques:- Write a program to check graph is bipartite or not , what will be the time complexity.
Asked In :- Zoox,
Right Answer:
To check if a graph is bipartite, you can use a BFS or DFS approach. Here’s a Python implementation using BFS:

```python
from collections import deque

def is_bipartite(graph):
color = {}
for node in graph:
if node not in color:
queue = deque([node])
color[node] = 0 # Start coloring with 0
while queue:
current = queue.popleft()
for neighbor in graph[current]:
if neighbor not in color:
color[neighbor] = 1 - color[current] # Alternate color
queue.append(neighbor)
elif color[neighbor] == color[current]:
return False
return True
```

The time complexity of this algorithm is O(V + E), where V is the number of vertices and E is the number of edges in the graph.
Ques:- Give a sorted array of huge size. The array cannot fit in memory. How would you do binary search in such a array?
Asked In :-
Right Answer:
To perform a binary search on a sorted array that cannot fit in memory, you can use the following approach:

1. **Determine the Size of the Array**: Use a method to find the total number of elements in the array, such as reading chunks of the array until you reach the end.

2. **Binary Search with External Storage**:
- Set the initial low and high indices for the search.
- Calculate the mid index: `mid = (low + high) / 2`.
- Read the element at the mid index from the external storage.
- Compare the mid element with the target value:
- If it matches, return the index.
- If the target is less than the mid element, update the high index to `mid - 1`.
- If the target is greater than the mid element, update the low index to `mid + 1`.
- Repeat the process until the target is found or the low index exceeds the high
Ques:- In a X's and 0's game (i.e. TIC TAC TOE) if you write a program for this give a fast way to generate the moves by the computer. I mean this should be the fastest way possible. T
Asked In :-
Right Answer:
To generate moves for a Tic Tac Toe game quickly, implement a Minimax algorithm with alpha-beta pruning. This approach evaluates possible future game states and chooses the optimal move for the computer while minimizing the opponent's chances of winning. Use a scoring system to evaluate board states: +10 for a win, -10 for a loss, and 0 for a draw. This allows the computer to make the best possible move efficiently.
Ques:- Given an unsorted array of numbers, Find a set of all the pythagorean triplets. e.g. Input array: [12,3,5,8,9,15,17,13] output set: {(3,4,5), (5,12,13), (8,15,17)} Try to minimize time complexity to O(n) if possible.
Asked In :-
Right Answer:
To find all Pythagorean triplets in an unsorted array with a time complexity of O(n), you can use the following approach:

1. Create a set to store the squares of the numbers in the array.
2. Iterate through each pair of numbers in the array, calculate the sum of their squares, and check if the result exists in the set of squares.

Here’s a Python implementation:

```python
def find_pythagorean_triplets(arr):
squares = {x * x for x in arr}
triplets = set()

for i in range(len(arr)):
for j in range(i + 1, len(arr)):
c_square = arr[i] * arr[i] + arr[j] * arr[j]
if c_square in squares:
c = int(c_square**0.5)
triplet = tuple(sorted((arr[i], arr[j], c)))
triplets.add(triplet)

return triplets

#
Ques:- Differences between class and structure?
Right Answer:
1. **Default Access Modifier**: In a class, the default access modifier is `private`, while in a structure, it is `public`.
2. **Inheritance**: Classes support inheritance, allowing one class to inherit from another, whereas structures do not support inheritance.
3. **Memory Allocation**: Classes are reference types and are allocated on the heap, while structures are value types and are allocated on the stack.
4. **Nullability**: Class instances can be null, but structures cannot be null unless they are defined as nullable types.
5. **Performance**: Structures can be more efficient for small data types due to stack allocation, but classes are more suitable for larger, complex objects.
Ques:- We have a file containing all product IDs. Write a code to retrieve all the Unique IDs that start with 'b' and doesn't have any special characters in it.
Asked In :-
Right Answer:
```python
def get_unique_ids(file_path):
unique_ids = set()
with open(file_path, 'r') as file:
for line in file:
product_id = line.strip()
if product_id.startswith('b') and product_id.isalnum():
unique_ids.add(product_id)
return list(unique_ids)

# Example usage
# unique_ids = get_unique_ids('product_ids.txt')
```
Ques:- How can we associate a single codebehind file with two aspx pages.eg. We have two files First.aspx and Second.aspx and we have cs files codebehind.cs in which we want to write code for both files. Then how we will execute this cs file for both of the aspx
Asked In :-
Right Answer:
To associate a single code-behind file with two ASPX pages, you can set the `Inherits` attribute in both ASPX pages to the same class defined in the code-behind file. For example:

In `First.aspx`:
```aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="codebehind.cs" Inherits="SharedCodeBehind" %>
```

In `Second.aspx`:
```aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="codebehind.cs" Inherits="SharedCodeBehind" %>
```

Ensure that the class in `codebehind.cs` is named `SharedCodeBehind`. This way, both ASPX pages will use the same code-behind file.
Ques:- Given an array A of positive integers. Convert it to a sorted array with minimum cost. The only valid operation are: 1) Decrement with cost = 1 2) Delete an element completely from the array with cost = value of element
Asked In :-
Right Answer:
To convert the array A to a sorted array with minimum cost, follow these steps:

1. Sort the array A to get the target sorted array.
2. For each element in the original array, compare it with the corresponding element in the sorted array:
- If the original element is greater than the sorted element, calculate the cost to decrement it to the sorted value.
- If the original element is less than the sorted element, consider deleting the original element (cost = value of the original element).
3. Accumulate the minimum cost for each element based on the above comparisons.

The final cost will be the sum of all the minimum costs calculated for each element.
Ques:- You have given a dictionary and a string, you need to separate words that are in dictionary. ex – catsanddog (here cat and cats both can be in dictionary) output – cat,cats,sand,dog
Asked In :-
Right Answer:
To solve the problem, you can use a backtracking approach to find all possible combinations of words from the dictionary that can form the given string. Here’s a concise solution in Python:

```python
def word_break(s, word_dict):
def backtrack(start, path):
if start == len(s):
result.append(','.join(path))
return
for end in range(start + 1, len(s) + 1):
word = s[start:end]
if word in word_dict:
backtrack(end, path + [word])

result = []
backtrack(0, [])
return result

# Example usage
dictionary = {"cat", "cats", "sand", "dog"}
string = "catsanddog"
output = word_break(string, dictionary)
print(output) # Output: ['cat,cats,sand,dog']
```

This code will return all combinations of words from the dictionary that can form the input string.
Ques:- Let A be a real valued matrix of order n*n already stored in memory. Its (i, j)-th element is denoted by a[i, j]. The elements of the matrix A satisfy the following property:
Asked In :-
Right Answer:
Please provide the specific property or condition that the elements of the matrix A satisfy for me to give a correct answer.
Ques:- U know the max number and min number is always zero.. u will be given pairs.. u need to see whether they have any gaps.. ex1: max no:20 pairs: 11-15, 0-5, 18-20, 14-19, 6-13
Asked In :- ttec,
Right Answer:
To check for gaps in the given pairs, first, create a list of all the numbers covered by the pairs. Then, sort this list and check for any consecutive numbers. If there are any missing numbers between the minimum and maximum, then there is a gap.

For the example provided (max: 20, pairs: 11-15, 0-5, 18-20, 14-19, 6-13), the covered numbers are: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20.

The gaps are: 7, 8, 9, 10, 16, 17.

Thus, there are gaps in the pairs.
Ques:- Given a word,convert it into a pallindrome with minimum addition of letters to it.letters can be added anywhere in the word.for eg if amazon is given result shud be amazonnozama .give a optimize soln
Asked In :-
Right Answer:
To convert a word into a palindrome with the minimum addition of letters, you can follow these steps:

1. Reverse the given word.
2. Find the longest prefix of the original word that matches a suffix of the reversed word.
3. The characters that do not match will need to be added in front of the original word.

For example, for the word "amazon":
- The reverse is "nomaza".
- The longest matching prefix-suffix is "a".
- Add "nomaz" in front of "amazon" to get "nomazamazon".

Thus, the result is "nomazamazon".

In general, the result can be constructed as:
`original_word + (reversed_original_word - longest_matching_prefix)`.
Ques:- Explain merge sort and quick sort, and compare them.
Asked In :-
Right Answer:
**Merge Sort:**
Merge sort is a divide-and-conquer algorithm that splits an array into two halves, recursively sorts each half, and then merges the sorted halves back together. It has a time complexity of O(n log n) and is stable, meaning it preserves the order of equal elements.

**Quick Sort:**
Quick sort is also a divide-and-conquer algorithm that selects a 'pivot' element from the array, partitions the other elements into those less than and greater than the pivot, and recursively sorts the partitions. Its average time complexity is O(n log n), but in the worst case, it can degrade to O(n²). Quick sort is generally not stable.

**Comparison:**
- **Time Complexity:** Both have O(n log n) average time complexity, but quick sort can be O(n²) in the worst case.
- **Space Complexity:** Merge sort requires O(n) additional space for the temporary arrays, while quick sort is in-place and requires O(log n


The Tech Architect section on takluu.com is dedicated to professionals aiming to lead the design and implementation of complex software systems. A Tech Architect plays a pivotal role in bridging business needs with technology solutions, ensuring that applications are scalable, maintainable, and aligned with organizational goals.

This category covers critical areas including system design principles, software architecture patterns (like microservices, SOA, MVC), cloud architecture, security best practices, API design, and performance optimization. You will also explore architecture documentation, stakeholder communication, and technology evaluation techniques.

Our content provides deep insights into both theoretical concepts and practical challenges faced by tech architects in real projects. Interview questions focus on problem-solving skills, architectural trade-offs, decision-making under constraints, and aligning technology stacks with business requirements.

Whether you’re preparing for roles like Technical Architect, Solution Architect, Enterprise Architect, or Lead Developer, this section equips you with the knowledge to explain complex designs clearly, defend your architectural choices, and demonstrate leadership in technology planning.

At Takluu, we combine detailed explanations with scenario-based questions and case studies to ensure you are ready for both technical and behavioral rounds in tech architect interviews. Our goal is to empower you to design robust solutions and take ownership of technology roadmaps confidently.

Prepare with us and take the next step in your career to become a successful Tech Architect who drives innovation and delivers impactful technology strategies.

AmbitionBox Logo

What makes Takluu valuable for interview preparation?

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