TIME AND SPACE COMPLEXITY / ONLINE JUDGE › ONLINE JUDGE
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.
| PLATFORM | COMMON SUBMISSION EXPERIENCE | WHAT YOU USUALLY CONTROL |
|---|---|---|
| LeetCode | Function or method based interface | The requested method and its algorithm |
| GeeksforGeeks | Often a provided class or method | The requested method, sometimes inside a required class |
| HackerRank | Scaffolded challenge with a supplied structure | The requested function or the marked part of the scaffold |
| Codeforces | Complete program with standard input and standard output | Input handling, algorithm, and output |
| CodeChef | Complete program, often with one or more test cases | Input handling, algorithm, and exact output |
| AtCoder | Complete program with standard input and standard output | Input handling, algorithm, and exact output |
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.
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.
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.#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;
}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.
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.
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 FEATURE | HOW IT CHANGES YOUR WORK AROUND THE SUM TASK | PLATFORMS WHERE IT IS COMMONLY VISIBLE |
|---|---|---|
| Topic-based problem lists | Help you collect exercises by arrays, loops, or another concept | LeetCode, GeeksforGeeks, HackerRank |
| Scheduled contests | Add time pressure and force quick input, output, and submission decisions | Codeforces, CodeChef, AtCoder, HackerRank |
| Ratings | Turn contest performance into a progress signal for timed problem solving | Codeforces, CodeChef, AtCoder, LeetCode |
| Editorials | Show an official explanation after you attempt the task | LeetCode, Codeforces, CodeChef, AtCoder, GeeksforGeeks |
| Discussions | Expose alternative explanations, code styles, and questions from other learners | LeetCode, GeeksforGeeks, HackerRank |
| Language support | Determines whether your preferred C++ or Java version and libraries are available | All named platforms, with different version details |
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.
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.
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.
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.