Collection of coding questions appearing in online assessment of VMware during campus placements at IIT/NITs, and other top engineering colleges in India.
- Backspace String Compare [IIT-BHU'22]
- Connected Groups [IIT-BHU'22]
Two strings are said to be the same if they are of the same length and have the same character at each index. Backspacing in a string removes the previous character in the string.
Given two string containing lowercase English letters and the character
In the first string, one
Complete the function compareStrings
.
compareStrings
has the following parameter(s):
-
$string \ \ s_1$ : the first string -
$string \ \ s_2$ : the second string
-
$int$ : either$0$ or$1$
$1 \leq length \ \ of \ \ s_1 \leq 2 \times 10^5$ $1 \leq length \ \ of \ \ s_2 \leq 2 \times 10^5$ - Both
$s_1$ and$s_2$ contain lowercase English letters and/or the character$'\#'$ only.
Sample Input | Sample Output |
yf#c#
ayy#k#pp## |
1 |
Both the string
Relationships between people may be represented in a matrix as a series of binary digits. For example, the direct relationships for person
Consider the following relationships matrix:
Persons
Determine the number of groups represented in a matrix.
Complete the function countGroups
.
countGroups
has the following parameter(s):
-
$string \ \ related[n]$ : an array of strings of binary digits$related[i]$ that represent connections of people
-
$int$ : an integer that represents the number of groups of people
$1 \leq n \leq 300$ $0 \leq i \lt n$ $|related| = n$ - Each
$related[i]$ contains a binary string of$n$ zeros and ones.$related$ is a square matrix.
Sample Input | Sample Output |
4
1100
1110
0110
0001 |
2 |
Squares highlighting a connection between two people are highlighted in green. Each of the people is known to self, so they are highlighted in gray.
There are
There are
Because a relation is transitive, the sets of people
The remaining person,
There are a total of