Your AI-powered LeetCode & DSA mentor for Claude Code and Claude.ai. Master algorithms through intelligent guidance, progressive hints, and pattern recognition training—not just copy-pasting solutions. Features: Mock interviews, code review, multi-language support (Python, Java, C++, JS, Go). Learn to think like a senior engineer. 🥋
git clone https://github.com/karanb192/algo-sensei.gitYour AI-powered LeetCode & DSA mentor for Claude Code and Claude.ai. Master algorithms through intelligent guidance, progressive hints, and pattern recognition training—not just copy-pasting solutions. Features: Mock interviews, code review, multi-language support (Python, Java, C++, JS, Go). Learn to think like a senior engineer. 🥋
No install command available. Check the GitHub repository for manual installation instructions.
git clone https://github.com/karanb192/algo-senseiCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Act as Algo Sensei, my AI-powered LeetCode mentor. I'm preparing for [COMPANY] interviews in [INDUSTRY]. Guide me through [PROBLEM] in [PROGRAMMING_LANGUAGE]. Provide progressive hints and explain the thought process behind the solution, not just the code. Focus on pattern recognition and problem-solving strategies.
# Algo Sensei's Solution Guide
## Problem: Two Sum
### Understanding the Problem
The problem requires us to find two numbers in an array that add up to a specific target. The solution must return the indices of these two numbers.
### Initial Thoughts
A brute-force approach would involve checking every possible pair of numbers in the array, which would have a time complexity of O(n²). However, we can optimize this using a hash map to reduce the time complexity to O(n).
### Optimized Solution
```python
def two_sum(nums, target):
num_map = {}
for i, num in enumerate(nums):
complement = target - num
if complement in num_map:
return [num_map[complement], i]
num_map[num] = i
return []
```
### Explanation
1. **Initialization**: We start by creating an empty dictionary `num_map` to store the numbers and their indices.
2. **Iteration**: We iterate through the array using `enumerate` to get both the index and the value of each number.
3. **Complement Calculation**: For each number, we calculate its complement (i.e., the value needed to reach the target sum).
4. **Check for Complement**: If the complement exists in `num_map`, we return the indices of the complement and the current number.
5. **Update Map**: If the complement is not found, we add the current number and its index to `num_map`.
### Edge Cases
- **No Solution**: If no two numbers add up to the target, the function returns an empty list.
- **Duplicate Numbers**: The solution handles duplicate numbers correctly by returning the first occurrence of the complement.
### Time and Space Complexity
- **Time Complexity**: O(n), where n is the number of elements in the array. This is because we traverse the list containing n elements only once. All dictionary operations are O(1) on average.
- **Space Complexity**: O(n), where n is the number of elements in the array. This is due to the extra space required for the dictionary.
### Mock Interview Practice
To further solidify your understanding, try solving similar problems like '3Sum' and '4Sum'. These problems build on the same principles but add additional layers of complexity.
### Next Steps
1. **Practice**: Solve similar problems on LeetCode to reinforce your understanding.
2. **Review**: Go through the solution again and try to explain it to someone else.
3. **Optimize**: Think about how you can further optimize the solution or handle edge cases more efficiently.
Good luck with your preparation for [COMPANY] interviews in [INDUSTRY]!Scalable robotic training data solutions
AI assistant built for thoughtful, nuanced conversation
IronCalc is a spreadsheet engine and ecosystem
Customer feedback management made simple
Enterprise workflow automation and service management platform
Automate your spreadsheet tasks with AI power