Solution - NEOPAT Cycle1
Solution - NEOPAT Cycle1
Test Summary
No. of Sections: 4
No. of Questions: 24
Total Duration: 120 min
Section Summary
● No. of Questions: 10
● Duration: 10 min
Additional Instructions:
None
TATA
TATA Elxsi
Elxsi
Runtime Error
Q2. What is the worst-case time complexity of inserting a node in a doubly linked list?
O(n log n)
O(log n)
O(n)
O(1)
24880
35478
12563
One pointer
Two pointers
Three pointers
Q5. Is it possible to create a doubly linked list using only one pointer for every node?
Not Possible
128
129
130
131
82 82 82 82 82 82
888888
222222
28 28 28 28 28 28
Q8. The concatenation of two lists can be performed in O(1) time. Which of the following variations of linked list can be used?
Q9. In the linked list, each node contains a minimum of two fields. One field is a data field to store the data second field is?
Pointer to character
Pointer to integer
Pointer to node
Section Summary
● No. of Questions: 10
● Duration: 10 min
Additional Instructions:
None
12
13
10
arning
Learning
Learning
Learning
Learning
Learning
Learning
a
Learning
Learning
Learning
Learning
arning
Learning
Learning
a
Consider the below program and predict the output for the same.
1 C = 100
2 for i = 1 to n do
3 for j = 1 to n do
4 {
5 Temp = A[i][j] + C
6 A[i][j] = A[j][i]
7 A[j][i] = Temp - C
8 }
9 for i = 1 to n do
10 for j = 1 to n do
11 Output(A[i][j]);
Adding 100 to the upper diagonal elements and subtracting 100 from
diagonal elements of A
LCM of 20 and 15 is 35
LCM of 15 and 20 is 60
LCM of 20 and 15 is 60
LCM of 15 and 20 is 61
hh
oo
ll
ee
Q9. Which of the following will print the value 2 for the given code?
1 #include <stdio.h>
2
3 int main() {
4 int arr[10][20][30] = {0};
5 arr[3][2][1] = 2;
6 return 0;
7 }
printf("Value at arr[3][2][1]:arr[3][2][1]);
44
88
16 16
32 32
22
44
66
88
22
11
22
11
12
34
56
78
Section Summary
● No. of Questions: 2
● Duration: 50 min
Additional Instructions:
None
Bob is attending a seminar on coding, which makes learning more interesting. During the seminar session, he was given a task to
find the frequency of a character.
Input Format
Output Format
Hello 0
L
Vanessa is learning about the doubly linked list and is eager to play around with it. She decides to find out how the elements are
inserted in the list and understands that the insertion happens in reverse order. Now she plans to print the original list and reverse
list one below the other.
Input Format
Output Format
The output displays the original list and the reversed list one below the other.
1 2 3 4 5 5 4 3 2 1
1 2 3 4 5
Section Summary
● No. of Questions: 2
● Duration: 50 min
Additional Instructions:
None
Paul and Peter are friends. They are bored of playing football.
So, Paul gave an array arr of size N to Peter. Peter's task is to find the minimum sum subsequence from the array such that at
least one value among all groups of four consecutive elements is picked.
Input Format
The first line of input contains an integer N denoting the size of the array arr.
The next line contains N space-separated integers, denoting the elements of the array.
Output Format
The output prints the minimum sum subsequence such that at least one value among all groups of four consecutive elements is picked.
Constraints
1 <= N <= 50
1 <= arr[i] <= 100
8 6
1 2 3 4 5 6 7 8
6 35
30 99 63 35 91 64
A statistician collected data on the heights of students in a class and wanted to visualize the distribution using a histogram. The
data consists of the heights of 20 students, with each height value ranging from 1 to 10 (inclusive).
Input Format
The first line of input consists of the number of histogram bars (maximum 20).
The second line of input consists of the heights of students (values between 1 and 10), separated by space.
Output Format
If the input is valid, the program should output the histogram, with each row representing the given input value, using the 'x' format.
If the input is invalid, i.e., not within the valid range, the program should output "Invalid".
Constraints
1 ≤ inputValue ≤ 20
5 x
1 4 5 3 2 xxxx
xxxxx
xxx
Sample Input Sample Output
4 xxx
3 4 9 10 xxxx
xxxxxxxxx
xxxxxxxxxx
Sample Input Sample Output
0 Invalid
21 Invalid
Could not connect to the reCAPTCHA service. Please check your internet connection and reload to get a reCAPTCHA challenge.
Answer Key & Solution
Section 1 - MCQ Easy
Q1
TATA Elxsi
Solution
No Solution
Q2
O(n)
Solution
No Solution
Q3
24880
Solution
No Solution
Q4
Two pointers
Solution
No Solution
Q5
Yes, possible by storing XOR of addresses of previous and next nodes
Solution
No Solution
Q6
129
Solution
No Solution
Q7
82 82 82 82 82 82
Solution
No Solution
Q8
Circular doubly linked list
Solution
No Solution
Q9
Pointer to node
Solution
No Solution
Q10
Memory size occupied by sample : 24
Solution
No Solution
Solution
No Solution
Q2
16
Solution
No Solution
Q3
arning
Learning
Learning
Solution
No Solution
Q4
The matrix A itself
Solution
No Solution
Q5
1
Solution
No Solution
Q6
LCM of 15 and 20 is 60
Solution
No Solution
Q7
0
Solution
No Solution
Q8
ee
Solution
No Solution
Q9
printf("Value at arr[3][2][1]: %d\n", arr[3][2][1]);
Solution
No Solution
Q10
22
44
66
88
Solution
No Solution
Input Output
Weightage - 20
Input Output
Weightage - 20
Input Output
Join the programming session 3
s
Weightage - 10
Input Output
Weightage - 40
Input Output
Weightage - 10
Hello 0
L
Solution
#include <stdio.h>
int main() {
char str[1000], ch;
int count = 0;
printf("%d", count);
return 0;
}
Q2
Test Case
Input Output
1 164 98 61 65 65 61 98 164 1
1 164 98 61 65
Weightage - 20
Input Output
Weightage - 20
Input Output
Weightage - 40
Input Output
Weightage - 20
1 2 3 4 5 5 4 3 2 1
1 2 3 4 5
Solution
#include <stdio.h>
#include <stdlib.h>
struct Node
{
int data;
struct Node *next;
struct Node *prev;
};
void reverse(struct Node **head_ref);
void push(struct Node** head_ref, int new_data);
void printList(struct Node *node);
/* UTILITY FUNCTIONS */
/* Function to insert a node at the beginging of the Doubly Linked List */
void push(struct Node** head_ref, int new_data)
{
/* allocate node */
struct Node* new_node =
(struct Node*) malloc(sizeof(struct Node));
#include <iostream>
using namespace std;
struct Node {
int data;
Node* next;
Node* prev;
};
/* UTILITY FUNCTIONS */
/* Function to insert a node at the beginging of the Doubly Linked List */
void push(Node** head_ref, int new_data) {
/* allocate node */
Node* new_node = new Node();
int main() {
Node* head = nullptr;
int val;
printList(head);
reverse(&head);
cout << endl;
printList(head);
return 0;
}
Input Output
14 122
06 83 23 75 84 27 39 49 26 60 70 46 87 65
Weightage - 10
Input Output
25 158
43 45 62 53 18 86 72 59 90 03 14 13 93 20 94 48
Weightage - 20
Input Output
34 197
71 55 42 24 54 67 16 31 10 57 25 50 97 02 58 33
Weightage - 20
Input Output
42 257
43 45 62 53 18 86 72 59 90 03 14 13 93 20 94 48
Weightage - 25
Input Output
50 334
70 46 87 65 79 32 81 28 01 78 43 45 62 53 18 86
Weightage - 25
8 6
1 2 3 4 5 6 7 8
6 35
30 99 63 35 91 64
Solution
#include <stdio.h>
int dp[n];
dp[0] = a[0];
for (int i = 1; i < 4; i++) {
dp[i] = a[i];
}
for (int i = 4; i < n; i++) {
dp[i] = dp[i - 4] + a[i];
for (int j = 1; j < 4; j++) {
dp[i] = min(dp[i], dp[i - j] + a[i]);
}
}
return min(dp[n - 1], min(dp[n - 2], min(dp[n - 3], dp[n - 4])));
}
int main() {
int n;
scanf("%d", &n);
int a[n];
for (int i = 0; i < n; i++) {
scanf("%d", &a[i]);
}
printf("%d", minSum(a, n));
return 0;
}
Q2
Test Case
Input Output
3 xxxx
4 3 2 xxx
xx
Weightage - 10
Input Output
5 xxxxx
5 4 3 9 4 xxxx
xxx
xxxxxxxxx
Weightage - 15
Input Output
8 x
1 3 4 7 2 5 6 9 xxx
xxxx
xxxxxxx
Weightage - 15
Input Output
4 xxxx
4 6 9 10 xxxxxx
xxxxxxxxx
xxxxxxxxxx
Weightage - 10
Input Output
10 xxxx
4 5 6 3 2 1 6 4 3 4 xxxxx
xxxxxx
xxx
Weightage - 20
Input Output
20 xxxx
4 3 2 1 5 6 7 8 9 10 2 3 5 3 5 6 4 3 2 1 xxx
xx
x
Weightage - 20
Input Output
23 Invalid
Weightage - 10
5 x
1 4 5 3 2 xxxx
xxxxx
xxx
Sample Input Sample Output
4 xxx
3 4 9 10 xxxx
xxxxxxxxx
xxxxxxxxxx
0 Invalid
21 Invalid
Solution
#include <stdio.h>
int main() {
int i, j;
int inputValue, hist_value = 0;
scanf("%d", &inputValue);
return 0;
}