Get best answers to any doubt/query/question related to programming , jobs, gate, internships and tech-companies. Feel free to ask a question and you will receive the best advice/suggestion related to anything you ask about software-engineering , development and programming problems .

0 like 0 dislike

3 Answers

0 like 0 dislike
 
Best answer

These are the only two coding questions in the online assessment : 

 

  1. Given two strings str1 and str2. We say that str2 divides str1 if it's possible to concatenate multiple str2 to get str1. For example, ab divides abab. if str2 does not divide str1, return -1. Otherwise, return the smallest string str3 such that str3 divides both str1 and str2.
  2. Given an array of scores, and an integer k. Player with the same score will have the same rank, and the rank of the player is "the number of players with higher score" + 1. For instance, given scores = [10, 20, 20, 40], the corresponding rank is [4, 2, 2, 1]. Only players with a rank <= k can qualify for the next round. Return the number of player that qualify for the next round.
by Expert (144,420 points)
0 like 0 dislike
by Expert (144,420 points)
0 like 0 dislike

problem 2 can be solved like this:->

 

void solve() {

 

int n; cin >> n;
vector<int>p(n);
fo(i, n) {
    cin >> p[i];
}
int k; cin >> k;

sort(p.begin(), p.end(), greater<int>());

map<int, int>mp;
int rank = 1;

for (auto x : p) {

    if (!mp.count(x))
        mp[x] = rank;
    rank++;
}
int count = 0;
for (auto x : p) {
    if (mp[x] <= k)
        count++;
}

cout << count << endl;

 

}

by Expert (144,420 points)
...