DSA SheetLesson · no judge

TIME AND SPACE COMPLEXITY / ONLINE JUDGEONLINE JUDGE

Popular Online Platforms: The Judge Shapes the Submission

Reading · 7 minQuiz · 5 questions2 code drills · run onlyGenerated by gpt-5.6-luna · Aug 22 · reviewed Aug 23

Popular judges can test the same algorithm through different interfaces

Suppose the task is to add the four values in [4, 2, 7, 1]. The algorithm is always the same: start at 0, visit each value, add it to the total, and produce 14. The submission experience is not always the same. Some platforms call a method you provide, while others run your complete program and compare what it prints.

PLATFORMCOMMON SUBMISSION EXPERIENCEWHAT YOU USUALLY CONTROL
LeetCodeFunction or method based interfaceThe requested method and its algorithm
GeeksforGeeksOften a provided class or methodThe requested method, sometimes inside a required class
HackerRankScaffolded challenge with a supplied structureThe requested function or the marked part of the scaffold
CodeforcesComplete program with standard input and standard outputInput handling, algorithm, and output
CodeChefComplete program, often with one or more test casesInput handling, algorithm, and exact output
AtCoderComplete program with standard input and standard outputInput handling, algorithm, and exact output
The same sum task appears in different submission shapes.

For the sum task, a function-based platform may secretly hold the array [4, 2, 7, 1], call your method, and check that it returns 14. A full-program platform instead gives your program n = 4 and the four values through standard input. Your program must calculate the same total and write only 14 to standard output. The mathematics does not change, but the boundary between your code and the judge does.

The required code wrapper is part of an accepted submission

Look at the two C++ forms below. The loop that adds the values is unchanged. In the first form, the judge owns the caller and supplies the array. In the second form, your complete program owns main, reads n and the values, and prints the answer. The surrounding code is different because the two judges assign ownership differently.

CPPA function-based submission. The judge owns the caller and input.
int sumArray(const vector<int>& a) {
    int total = 0;
    for (int value : a) {
        total += value;
    }
    return total;
}

// The judge calls sumArray({4, 2, 7, 1}) and checks for 14.
CPPA complete-program submission. The program reads 4 and 4 2 7 1, then prints 14.
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    int total = 0;
    for (int value : a) {
        total += value;
    }

    cout << total << '\n';
    return 0;
}
CHECKPOINT 1Not answered

A platform-provided method already receives [4, 2, 7, 1]. Which submission fits that interface and returns 14?

Checkpoints are not graded. They are here so you catch yourself before the quiz does — stuck, ask the tutor on the right.

two accepted submission shapes for summing [4, 2, 7, 1]A side-by-side comparison shows two submissions for the array [4, 2, 7, 1]. On the left, a hidden driver passes the array to a submitted function, the shared loop computes 14, and the function returns 14. On the right, a complete submitted program reads n = 4 and the values 4 2 7 1 from standard input, runs the same loop, and prints only 14 to standard output.provided methodinput: [4, 2, 7, 1]returns 14shared sum loopadd 4, 2, 7, 1 → 14hidden driverpasses array; checks 14submitted mainreads n = 4; valuesstandard input44 2 7 1shared sum loopadd 4, 2, 7, 1 → 14stdout: 1414read stdinprintFUNCTION-BASED SUBMISSIONFULL-PROGRAM SUBMISSIONSame loop; the judge owns the wrapper on the left, but you own input and output on the right.
The algorithm is unchanged, but the judge decides who owns the wrapper and input handling.

The wrapper includes more than the method or main function. It includes the exact class name, method name, parameter types, return type, input format, and output format that the platform expects. An extra label such as "answer = " is different from the required output 14. A missing class, an altered signature, an extra main function, or unexpected output can reject the submission before the judge can give credit for the sum.

A platform's practice style changes the skills surrounding the same task

The sum task is too small to reveal much about algorithmic difficulty, so keep its loop fixed and compare the work around it. On LeetCode and GeeksforGeeks, you may reach it through topic-based problem lists and focus on writing the requested method. HackerRank often places the method inside a scaffolded challenge, with instructions and test information around the code you edit.

Codeforces, CodeChef, and AtCoder commonly make you write the complete program for the input 4 followed by 4 2 7 1 and the output 14. Their contest settings make fast reading, exact input handling, debugging under time pressure, and repeated submissions part of the skill. A method-based exercise can hide those tasks because the platform handles the input and caller for you.

PRACTICE FEATUREHOW IT CHANGES YOUR WORK AROUND THE SUM TASKPLATFORMS WHERE IT IS COMMONLY VISIBLE
Topic-based problem listsHelp you collect exercises by arrays, loops, or another conceptLeetCode, GeeksforGeeks, HackerRank
Scheduled contestsAdd time pressure and force quick input, output, and submission decisionsCodeforces, CodeChef, AtCoder, HackerRank
RatingsTurn contest performance into a progress signal for timed problem solvingCodeforces, CodeChef, AtCoder, LeetCode
EditorialsShow an official explanation after you attempt the taskLeetCode, Codeforces, CodeChef, AtCoder, GeeksforGeeks
DiscussionsExpose alternative explanations, code styles, and questions from other learnersLeetCode, GeeksforGeeks, HackerRank
Language supportDetermines whether your preferred C++ or Java version and libraries are availableAll named platforms, with different version details
The fixed sum algorithm can support different practice goals.

The same fixed loop can therefore train different habits. A topic list helps you build a sequence of array exercises. An editorial helps you compare your reasoning with an official explanation. Discussions can reveal why another solution uses a different wrapper. A contest with ratings measures how well you handle time, implementation details, and several submissions, not merely whether you know how to add four numbers.

CHECKPOINT 2Not answered

You want to practise the sum task in a timed contest where you must write a full program that reads 4 and 4 2 7 1 and prints only 14. Which platform style is the best match?

Checkpoints are not graded. They are here so you catch yourself before the quiz does — stuck, ask the tutor on the right.

No single platform is the best choice for every practice goal

Choose a platform by the skill you want to practise, not by its popularity alone. For the sum task, first ask whether you want to concentrate on a method or practise the entire path from reading input to printing output. Then check whether you want guided topic practice, a timed contest, a rating, an editorial, discussions, or a particular C++ or Java version.

  • Choose a method-based interface when you want the platform to remove input and wrapper work so you can focus on the algorithm.
  • Choose a complete-program platform when you want to practise standard input, standard output, and the exact structure used in a contest.
  • Choose topic-based lists when you need a guided route through array and loop problems.
  • Choose contests and ratings when you want to measure decisions made under time pressure.
  • Check editorials and discussions when explanations and alternative approaches are part of your learning goal.
  • Check language support before committing to a platform, especially when your code depends on a particular C++ or Java version.

Using more than one platform helps only when each one has a clear job. You might use a method-based platform to practise the sum logic inside a focused array list, then use a complete-program contest platform to practise reading 4 and 4 2 7 1 and printing exactly 14. Carry the algorithm between them, but rewrite the wrapper that belongs to the new judge. That separation prevents a correct loop from being mistaken for a universally correct submission.

Previous · Why, What and How?Next part · Quiz