Find Interview Questions for Top Companies
Ques:- Write code to find the middle element of a linked list
Right Answer:
```python
class ListNode:
def __init__(self, value=0, next=None):
self.value = value
self.next = next

def find_middle(head):
slow = head
fast = head
while fast and fast.next:
slow = slow.next
fast = fast.next.next
return slow.value
```
Ques:- Given a matrix.Write a code to print the transpose of the matrix
Right Answer:
```python
def transpose_matrix(matrix):
return [[matrix[j][i] for j in range(len(matrix))] for i in range(len(matrix[0]))]

# Example usage:
matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
transposed = transpose_matrix(matrix)
print(transposed)
```


AmbitionBox Logo

What makes Takluu valuable for interview preparation?

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