Question: JP Morgan Chase, Recently Asked Online Assessment Questions (1st October 2023) | Identical Distribution | Missing words
2
Entering edit mode

ADD COMMENTlink 14 months ago Delta 2.9k
Entering edit mode
0

In which college these questions were asked?

 

ADD REPLYlink 14 months ago
Madhav Maheshwari
• 0
2
Entering edit mode

Q1. Solution. 

#include <bits/stdc++.h>

using namespace std;

 void checkmodulo(int x,map<int,int> &mpp){
        int i=2;
        while(i<=x){
            if(x%i==0){
                mpp[i]++;
            }
            i++;
        }
    }
int main()
{
    int arr[]={3,6,9,12,15};
    int n=5;
    map<int,int>mpp;
    for(int i=0;i<n;i++){
        checkmodulo(arr[i],mpp);
    }
    int maxi =0;
    for(auto it:mpp){
        if(it.second>maxi){
            maxi = it.second;
        }
    }
    cout<< n-maxi;
}
 

ADD COMMENTlink 14 months ago Aryan • 20
Entering edit mode
0

I understand that checkmodulo() is being used to count the number of factors of each element , and then we are returning the max number of factors any element in the array , but I dont see how this works ? Can someone explain 

ADD REPLYlink 14 months ago
Ayush Agarwal
• 20
Entering edit mode
0

Try to fing GCD of whole array. if >1 then return 0 else count number of odd numbers and return it

ADD REPLYlink 14 months ago
Yololo
• 20
Entering edit mode
0

Work out this testcase then bro:
16 9 9 9 9
Let me know how this works here.

ADD REPLYlink 3 months ago
Akash Singh
• 0
0
Entering edit mode

 

return (j==t.length());

}

ADD COMMENTlink 14 months ago Tarun Pratap Singh • 0
Entering edit mode
0

what type of solution is this

 

ADD REPLYlink 14 months ago
tejas tomar
• 0

Login before adding your answer.

Similar Posts
Loading Similar Posts