SECTION - CODING - ANSWER q2:- function helpTeacher(x1, y1, arr1) { const arr = arr1; //the input array const x = x1; //input 1 const y = y1; //input2 let obj = {}; //logic to get sum in column wise start for (let i = 0; i < y; i++) { let sum = 0; for (let j = 0; j < x; j++) { sum = sum + arr[j][i]; obj[i] = sum; } } //logic to get sum in column wise end //logic to find which column we want to neglect start const obj_array = Object.entries(obj); const sorted_obj_array = obj_array.sort((a, b) => a[1] - b[1]); const del_column = +sorted_obj_array[0][0]; //logic to find which column we want to neglect end //logic to get sum row wise without the ignored subject start let out_array = []; for (let i = 0; i < x; i++) { let sum = 0; for (let j = 0; j < y; j++) { if (j !== del_column) { sum = sum + arr[i][j]; } } out_array.push(sum); } //logic to get sum row wise without the ignored subject end console.log("out_array", out_array); //needed output } helpTeacher(3, 5, [ [75, 76, 65, 87, 87], [78, 76, 68, 56, 89], [67, 87, 78, 77, 65], ]);
Coding Solutions in JavaScript: Sol 1: const smallestSubstr = (input1: string, input2: string) => { // Array to record all the matching combinations debugger let list = [] let check = [...input2].every(char => input1.includes(char)) if (check) { for (let i = input2.length; i input1.slice(j, i + j).includes(char)) if (b) { list.push(input1.slice(j, i + j)) break; } } } } console.log('l::', list) console.log('The smallest substring containing', input2, 'is ::', list[0]) } else { console.log('Please enter a valid substring') } } ======== Sol 2: function calculateMarks(students, subjects, marks) { // Initialize an array to store the sum of marks for each subject. let subjectSums = Array(subjects).fill(0) // Iterate over the students and for each student, // iterate over the subjects to calculate the sum of marks for each subject. for (let i = 0; i < students; i++) { for (let j = 0; j < subjects; j++) { subjectSums[j] += marks[i][j] } } let minAverageIndex = 0 // Find the subject with the lowest average marks. // The average is calculated by dividing the sum of marks by the number of students for (let j = 1; j < subjects; j++) { if (subjectSums[j] / students < subjectSums[minAverageIndex] / students) { minAverageIndex = j } } // Initialize an array to store the total marks for each student. let studentTotals = Array(students).fill(0) // Iterate over the students and for each student, // iterate over the subjects to calculate the total marks, ignoring the subject with the lowest average. for (let i = 0; i < students; i++) { for (let j = 0; j < subjects; j++) { if (j !== minAverageIndex) { studentTotals[i] += marks[i][j] } } } // Return the array of total marks for each student. return studentTotals } console.log(calculateMarks(3, 3, [[50, 30, 70], [30, 70, 99], [99, 20, 30]])); // Output: [120, 129, 129]
its very helpful, Thankyou
Really helpful.
Thanks.
SECTION - CODING - ANSWER
q2:-
function helpTeacher(x1, y1, arr1) {
const arr = arr1; //the input array
const x = x1; //input 1
const y = y1; //input2
let obj = {};
//logic to get sum in column wise start
for (let i = 0; i < y; i++) {
let sum = 0;
for (let j = 0; j < x; j++) {
sum = sum + arr[j][i];
obj[i] = sum;
}
}
//logic to get sum in column wise end
//logic to find which column we want to neglect start
const obj_array = Object.entries(obj);
const sorted_obj_array = obj_array.sort((a, b) => a[1] - b[1]);
const del_column = +sorted_obj_array[0][0];
//logic to find which column we want to neglect end
//logic to get sum row wise without the ignored subject start
let out_array = [];
for (let i = 0; i < x; i++) {
let sum = 0;
for (let j = 0; j < y; j++) {
if (j !== del_column) {
sum = sum + arr[i][j];
}
}
out_array.push(sum);
}
//logic to get sum row wise without the ignored subject end
console.log("out_array", out_array); //needed output
}
helpTeacher(3, 5, [
[75, 76, 65, 87, 87],
[78, 76, 68, 56, 89],
[67, 87, 78, 77, 65],
]);
13 aptitude questions answer u marked wrong its Wednesday not Tuesday as 2012 is a leap year
Coding Solutions in JavaScript:
Sol 1:
const smallestSubstr = (input1: string, input2: string) => {
// Array to record all the matching combinations
debugger
let list = []
let check = [...input2].every(char => input1.includes(char))
if (check) {
for (let i = input2.length; i input1.slice(j, i + j).includes(char))
if (b) {
list.push(input1.slice(j, i + j))
break;
}
}
}
}
console.log('l::', list)
console.log('The smallest substring containing', input2, 'is ::', list[0])
} else {
console.log('Please enter a valid substring')
}
}
========
Sol 2:
function calculateMarks(students, subjects, marks) {
// Initialize an array to store the sum of marks for each subject.
let subjectSums = Array(subjects).fill(0)
// Iterate over the students and for each student,
// iterate over the subjects to calculate the sum of marks for each subject.
for (let i = 0; i < students; i++) {
for (let j = 0; j < subjects; j++) {
subjectSums[j] += marks[i][j]
}
}
let minAverageIndex = 0
// Find the subject with the lowest average marks.
// The average is calculated by dividing the sum of marks by the number of students
for (let j = 1; j < subjects; j++) {
if (subjectSums[j] / students < subjectSums[minAverageIndex] / students) {
minAverageIndex = j
}
}
// Initialize an array to store the total marks for each student.
let studentTotals = Array(students).fill(0)
// Iterate over the students and for each student,
// iterate over the subjects to calculate the total marks, ignoring the subject with the lowest average.
for (let i = 0; i < students; i++) {
for (let j = 0; j < subjects; j++) {
if (j !== minAverageIndex) {
studentTotals[i] += marks[i][j]
}
}
}
// Return the array of total marks for each student.
return studentTotals
}
console.log(calculateMarks(3, 3, [[50, 30, 70], [30, 70, 99], [99, 20, 30]])); // Output: [120, 129, 129]
Did you clear this assessment?
Ques 9 answer is C not A
Bhai kal interview gya aaj dekh rha hu video😢
Hi Bhai, mera kal assesment hai
any tip..please
Bhai ye video pura dekh lo, aur iske question practice kar lo, mere case me 60% matching question tha isse
10 ghante le ek sawal par