Add detailed inline comments explaining complex code logic
Add detailed inline comments to explain this code:
**Language:** {{LANGUAGE}}
**Complexity Level:** {{COMPLEXITY}} (basic/intermediate/advanced explanations)
**Target Audience:** {{AUDIENCE}} (junior developers/senior developers/non-technical)
**Code:**
```{{LANGUAGE}}
{{CODE}}
```
Add comprehensive inline comments that:
1. **Explain the "Why"**
- Why this approach was chosen
- What problem it solves
- Any trade-offs made
2. **Clarify Complex Logic**
- Step-by-step explanation of algorithms
- Loop invariants
- Conditional logic reasoning
3. **Document Assumptions**
- Input expectations
- Preconditions
- Invariants
4. **Highlight Important Details**
- Edge cases handled
- Performance considerations
- Potential gotchas
5. **Reference External Resources**
- Algorithm sources
- Related documentation
- Stack Overflow links for tricky solutions
Comment Style Guidelines:
- Use {{LANGUAGE}}'s conventional comment syntax
- Keep comments concise but informative
- Place comments above the code they describe
- Use block comments for complex sections
- Avoid stating the obvious
Return the fully commented code.Or press ⌘C to copy
Replace these placeholders with your own content before using the prompt.
[{LANGUAGE][{COMPLEXITY][{AUDIENCE][{CODE]