Hiver
Details
Job Status
Full Time (Employment + Internship Mandatory)
Criteria
| Study | Cutoff |
|---|---|
| X | 80% |
| XII | 80% |
| UG | 8 GPA |
Round 1
07/10/23
There were only 7 questions, 5 MCQ and 2 Coding, in 1h15m
Coding Questions
- Next Smallest Palindrome: Given a number as an array, find the next smallest palindrome.
vector<int> solve(vector<int> num) {
bool isPalin = false;
int n = num.size();
auto helper = [&] () {
int l = 0;
int r = n - 1;
int t, oldr, p;
while (l < r) {
oldr = num[r];
num[r] = num[l];
if (oldr > num[l]) {
t = r - 1;
while (t > 0) {
p = num[t];
++p;
if (p < 10) {
num[t] = p;
break;
}
else {
num[t] = 0;
}
--t;
}
--l;
++r;
}
++l;
--r;
}
if (l >= r) {
isPalin = true;
}
};
while (!isPalin) {
helper();
}
return num;
}
Covid Beds: There is a line of beds represented by 1’s and 0’s in a string, 1 means that the bed is occupied and 0 means that the bed is vacant. A partition is defined as such that it has exactly 2 occupied beds (this can also mean that the parition can have vacant beds too).
A partition is created by placing a temporary walls between any two beds.
Print the number of ways the walls can be placed such that partitions satisfying the conditions can be made. If no such partitions can be made, print -1.
Ex:
6 110011 Output: 3 - [11|0011, 110|011, 1100|11] 6 101101 Output: 1 - [101|101] 11 11001100011 Output: 12