0% found this document useful (0 votes)
4 views

questions_list

Uploaded by

surya191m
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

questions_list

Uploaded by

surya191m
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

### 1.

Replace every element with the greatest element on the right side
**Problem:**
Given an array of integers, replace every element with the greatest element to its
right. Replace the last element with -1.
**Example:**
Input: `{16, 17, 4, 3, 5, 2}`
Output: `{17, 5, 5, 5, 2, -1}`

---

### 2. Modify a Boolean matrix


**Problem:**
Given a Boolean matrix of size `M x N`, modify it such that if a cell `mat[i][j]`
is `1`, make all its adjacent cells `0`.

---

### 3. Equilibrium index of an array


**Problem:**
Find the index in an array such that the sum of elements to the left is equal to
the sum of elements to the right.
**Example:**
Input: `{-7, 1, 5, 2, -4, 3, 0}`
Output: `3`

---

### 4. Flood fill algorithm (like MS Paint)


**Problem:**
Given a 2D screen, a pixel `(x, y)`, and a new color, replace the pixel and all
adjacent pixels with the same color.
**Example:**
Input:
```
Screen: {{1, 1, 1}, {1, 0, 1}, {1, 1, 1}}
x = 1, y = 1, newColor = 2
Output:
Screen: {{2, 2, 2}, {2, 2, 2}, {2, 2, 2}}
```

---

### 5. Zig-zag matrix traversal


**Problem:**
Given a matrix, print its elements in a zig-zag fashion.
**Example:**
Input:
```
Matrix: {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}
Output: `1 2 4 7 5 3 6 8 9`
```

---

### 6. Remove duplicates in a string


**Problem:**
Remove duplicate characters in a string and replace them with the next unique
character.
**Examples:**
Input: `"Java1234"`
Output: `"Javb1234"`
Input: `"Python1223"`
Output: `"Python1234"`

---

### 7. Compare software versions


**Problem:**
Compare two software version strings and determine if they are **upgraded**,
**downgraded**, or **unchanged**.
**Example:**
Input: `Version1 = 4.8.2, Version2 = 4.8.4`
Output: `upgraded`

---

### 8. Subsets with sum equal to N


**Problem:**
Find all subsets of an array that sum to a given value.
**Example:**

You might also like