Site Message

Only Premium Users can view the Question

Site Message

Only Premium Users can view the Question

Site Message

Only Premium Users can view the Question

Site Message

Only Premium Users can view the Question

Site Message

Only Premium Users can view the Question

Site Message

Only Premium Users can view the Question

Site Message

Only Premium Users can view the Question

Site Message

Only Premium Users can view the Question

Site Message

Only Premium Users can view the Question

Site Message

Only Premium Users can view the Question

Site Message

Only Premium Users can view the Question

Site Message

Only Premium Users can view the Question

Question: Apple | SDE-1 | On Campus | 22nd November 2020
0
Entering edit mode

Format

  • 75 minutes
  • 2 coding problem + 8 MCQs
  • Remarks - Pretty easy, finished everything in 15-20minutes - no flex : )
    But seriously, no idea how this problemset will distinguish strong and weak candidates. Also hard to understand statements.

  • Problem 1

    Problem 2

    MCQ problems

ADD COMMENTlink 5.6 years ago mod2 870
Entering edit mode
1
Thanks for adding question, in MCQ two of them are filled wrong.
  1. Q2 - (B) option A B C D E F G HI
  2. Q8 - (B) (C)
ADD REPLYlink 5.6 years ago
admin
1.9k
0
Entering edit mode
Answers to MCQ questions marked in the question itself. Let me know if something's wrong, didn't cross verify MCQs.

Problem 1

/*
 * Complete the 'socialGraphs' function below.
 *
 * The function accepts INTEGER_ARRAY counts as parameter.
 */

void socialGraphs(vector counts) {
    vector g[200020];
    set tes;
    for (int i = 0; i < counts.size(); ++i) {
        g[counts[i]].push_back(i);
        tes.insert(counts[i]);
    }
    
    vector> op;
    for (auto xx: tes) {
        int i = 0;
        vector curs;
        for (auto yy: g[xx]) {
            curs.push_back(yy);
            //cout << yy << " ";
            ++i;
            if (i % xx == 0) {
                i = 0;
                //cout << "\n";
                op.push_back(curs);
                curs.clear();
            }
        }
    }
    sort(op.begin(), op.end());
    for (int i = 0; i < op.size(); i++) {
        for (auto xx: op[i]) cout << xx << " ";
        cout << "\n";
    }
}

Problem 2

/*
 * Complete the 'minTime' function below.
 *
 * The function is expected to return an INTEGER.
 * The function accepts following parameters:
 *  1. INTEGER_ARRAY processorTime
 *  2. INTEGER_ARRAY taskTime
 */
 
int minTime(vector ptime, vector task) {
    assert(ptime.size()*4 == task.size());
 
    sort(ptime.begin(), ptime.end());
    sort(task.begin(), task.end());
    reverse(task.begin(), task.end());
 
    int ans = 0;
    for (int i = 0; i < (int)task.size(); i += 4) {
        int j = i / 4;
        ans = max(ans, task[i]+ptime[j]);
    }
    return ans;
}
ADD COMMENTlink 5.6 years ago mod2 870

Login before adding your answer.

Similar Posts
Loading Similar Posts