Classical Variable names
Abstract
Classical variable names used in solutions to the 48 problems of LeetCode Top Easy, with references to the types of problems or algorithms they are used for, and the reason for the name when it's not obvious.
These names are purposely limited to these problems.
Why these names matter:
- Interviewers expect them.
- They compress explanation.
- They make standard patterns recognizable fast.
Generated with love by AI.
Array / two pointers¶
i,j: generic indicesleft, right: opposite ends, two-pointer scans, palindrome, reverse, partition-ish workread,write: in-place compaction problems (rationale: one pointer reads input, one writes kept values)lo,hi: inclusive bounds in binary search / divide and conquer (rationale: short for low and high)mid: middle index in binary search or recursive splitn,m,k: lengths or problem parameters (rationale: conventional short math-style names)
Hash map / set¶
seen: values already encounteredcounts: frequency tableneed: complement needed to complete a target, especially Two Sum
Linked list¶
head: first node of the listdummy: fake node before head to simplify edge casescur: current node while traversingprev: previous node or reversed prefixnxt: saved next node before pointer rewriteslow,fast: tortoise-hare or middle-finding pointerstail: end of an output or merged list
Tree¶
root: top nodenode: current node in DFS/BFSleft,right: child referencesstack: iterative DFSqueue: BFSdepth: current tree depth
Dynamic programming / greedy¶
dp: dynamic programming tablecur,best: current local answer and global bestprev1,prev2: previous states in rolling DPprofit,min_price: stock problemsacc: accumulator, especially XOR accumulation
Bit manipulation¶
ans: result being builtdigit: extracted decimal digitcount: bit count or loop count
Others¶
rows,cols,boxes: Sudoku constraint buckets