LeetCode
LeetCode is a website where you solve programming problems and submit your code for automated testing. It is commonly used to prepare for coding interviews.
Also known as: литкод
What LeetCode is
LeetCode is an online judge: it gives you a programming problem and runs your solution against test cases. Many of its problems focus on algorithms and data structures, such as searching an array or traversing a tree. Problems are labeled Easy, Medium, or Hard and can be filtered by topic. When someone describes a coding round as “LeetCode-style,” they usually mean a short algorithm problem, not necessarily one copied from the site.
What happens when you submit code
A problem statement defines the inputs, the expected output, and the constraints. For a typical algorithm problem, LeetCode provides a function or method signature. You fill in the implementation; the judge calls it for you, so you generally don't need to read from standard input or print the answer. Run lets you try examples or custom cases. Submit checks your solution against a larger suite that includes hidden tests. An Accepted result means the submission passed that suite within the limits. It doesn't tell you whether there is a simpler or more efficient approach.
Example: Valid Parentheses
Given a string containing only ()[]{}, check whether each opening bracket is closed by the matching type in the right order. ([]) is valid, but ([)] isn't: equal counts don't help when the closing order is wrong.
class Solution:
def isValid(self, s):
matching = {')': '(', ']': '[', '}': '{'}
stack = []
for char in s:
if char not in matching:
stack.append(char)
elif not stack or stack.pop() != matching[char]:
return False
return not stack
The stack holds opening brackets that haven't been matched yet. A closing bracket has to match the most recent unmatched opener, and the stack must be empty at the end. The solution runs in O(n) time for a string of length n and uses O(n) extra space in the worst case, such as a string made entirely of opening brackets.
How to practice for an interview
Before writing code, read the constraints and work through a small example by hand. Explain what your data structure tracks and why that information is enough. Then test cases that challenge different parts of the logic: ] closes a bracket that was never opened, ([)] closes the wrong type, and ([ leaves openers unmatched. That gives you more useful feedback than running three nearly identical valid strings.
The judge sees your code; an interviewer also wants to hear how you got there. Ask about ambiguous requirements, explain why your approach works, and state its time and space costs. If you already recognize the problem, try a variation instead of reciting your solution: what if the string also contains letters that should be ignored? LeetCode practice helps with algorithm rounds, but it doesn't replace practice at debugging, code review, or system design if the role calls for those skills.