LeetCode Language Selection: Run Code Is Not Submit
Pick a supported language by problem limits, treat Run Code as a sanity check, and verify edge cases before submitting hidden tests.
29 Jul 2026, 10:36 UTC

Decision: which language and when to submit
You open a LeetCode problem, write a solution, and press Run Code. The editor shows the expected output for the sample case. You press Submit and receive Wrong Answer or Time Limit Exceeded. The gap exists because Run Code checks only visible or custom-entered cases, while Submit runs hidden tests under problem-specific time and memory limits. Your language choice affects both results.
Useful takeaway: choose a language after reading the constraints, verify edge cases with custom input in Run Code, and treat Submit as the only accepted signal. Do not optimize for the runtime percentile shown after a run; it is relative to recent submissions and can fluctuate.
Constraints to check before choosing
- Input size: an input of 10^5 elements usually requires O(N log N) or O(N); O(N^2) may pass in C++ but time out in Python.
- Time limit: often one or two seconds. Interpreted languages may receive different limits than compiled languages.
- Memory limit: commonly 256 MB. Recursion-heavy or graph solutions can exceed it.
- Language availability: the editor dropdown shows supported languages for that problem, and availability can change. Some problems disable specific languages.
- Standard library: the built-in modules and data structures provided with the language. Python offers heapq, collections, and itertools; Java offers java.util; C++ offers the STL. Using unsupported modules causes compile or runtime errors.
Supported options compared
| Language | Typical advantage | Limit consideration | Best for |
|---|---|---|---|
| Python 3 | Concise syntax, rich built-ins | Slower raw execution; watch recursion and large loops | Straightforward implementations, prototyping |
| Java | Strong typing, java.util collections | JVM startup and memory overhead | Object-heavy designs, large data structures |
| C++ | Fast execution, STL | Manual memory risks, verbose syntax | Tight time limits, competitive programming |
| JavaScript | Familiar web syntax, no compile step | Number handling and BigInt edge cases | Quick iterations, string manipulation |
| Go | Fast compile, efficient concurrency | Smaller standard library than Java or C++ | Concurrent or pipeline-style solutions |
Trade-offs
Speed versus development time
C++ and Go are compiled and usually execute faster than Python or JavaScript for the same algorithm. If the problem has tight time limits and large inputs, a compiled language reduces the risk of Time Limit Exceeded. Python lets you write and debug faster, which matters more when limits are loose.
Memory and recursion
Deep recursion can overflow the stack or exceed memory limits. Python has a default recursion limit that may need adjustment, while C++ stack behavior depends on the environment. For graph problems with deep paths, consider an explicit stack or iterative approach regardless of language.
Large integers
Python handles arbitrarily large integers natively. In C++ or Java, large products or sums may overflow unless you use long long, BigInteger, or modular arithmetic. JavaScript uses BigInt for values beyond safe integer limits.
Concrete validation: custom edge case before Submit
Use this flow in the LeetCode web editor while logged into your account:
- Open the problem and read Constraints. Note the maximum input size and value range.
- Open the language selector and confirm your preferred language appears for this problem.
- Write a solution. Example placeholder structure for Python 3:
class Solution:
def solve(self, nums: list[int]) -> int:
# Replace with problem-specific logic
return sum(nums)
Where to run: LeetCode code editor, Run Code tab. Required permissions: a logged-in LeetCode account. Placeholders: replace solve and nums with the problem's required method name and parameters. Expected check: Run Code returns the expected output for the sample case. Risk: passing Run Code does not mean hidden tests will pass.
- Switch to Custom test case. Enter an edge case, such as the minimum array size, maximum value, duplicate elements, or empty input, depending on the problem constraints.
- Run Code again. If the output is wrong or the program errors, fix the logic before submitting.
- Press Submit. Possible verdicts: Accepted, Wrong Answer, Time Limit Exceeded, Memory Limit Exceeded, or Runtime Error. Accepted means hidden tests passed. Wrong Answer means the output did not match expected results. Time Limit Exceeded means the solution took too long. Memory Limit Exceeded means it used too much memory. Runtime Error means the program crashed.
If Submit returns Time Limit Exceeded, the algorithm complexity is likely too high for the limit, or the chosen language is too slow for that input size. Try the same algorithm in a compiled language or reduce allocations. If it returns Wrong Answer on a hidden case, reproduce a similar edge case with Custom test case and iterate.
Limitations
- Language availability, default versions, and resource limits are not guaranteed stable. Confirm the dropdown in the active editor before solving.
- Reported runtime and memory are relative to recent submissions and can fluctuate. Do not use them as absolute benchmarks.
- Some problems restrict or disable certain languages, and database or shell problems have environment-specific requirements.
- A successful Run Code result does not imply acceptance; hidden tests may include larger inputs or edge cases not shown in the editor.
Practical way to check the result
After submitting, open the submission detail page. Compare the verdict and reported runtime against your earlier Run Code result. If Accepted, the solution passed hidden tests. If not, use any failed case information provided to add a matching Custom test case in Run Code, fix the code, and submit again.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.