blu3-bird / blu3-bird/coffee-and-code
Team Challenge: Solve Two Sum (LeetCode #1)
- Dominant language
- CSS
- Stars
- 0
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
## Problem
**Two Sum** (LeetCode #1)
🔗 https://leetcode.com/problems/two-sum/
Given an array of integers `nums` and an integer `target`, return the indices of the two numbers that add up to `target`. You can assume exactly one valid answer exists, and you can't use the same element twice.
The full problem statement is posted at `DSA/problems/1.py`.
## Task
This one's assigned to everyone. Read the problem, solve it, and submit your own solution.
- Problem file (read only, don't edit): `DSA/problems/1.py`
- Your solution goes in: `DSA//1.py`
- Language: Python or C++, your pick (if you go with C++, name your file `1.cpp` instead, since a `.py` file can't hold C++ code)
## Concepts to Brush Up On
- Arrays: how they're indexed and traversed
- Hash Maps / Hash Tables: the key to turning the brute force O(n²) approach into an O(n) one
- Time and space complexity (Big-O)
- OOP basics in Python or C++: LeetCode wraps every solution inside a `class Solution`, so knowing how classes and methods work matters here
## Lectures & Resources
**Problem walkthrough**
- NeetCode, Two Sum solution and explanation (video): https://www.youtube.com/watch?v=KLlXCFG5TnA
- NeetCode, written solution covering brute force, sorting, and hash map approaches: https://neetcode.io/solutions/two-sum
**Hash Tables**
- Abdul Bari, Hashing Technique Simplified: https://www.youtube.com/watch?v=mFY0J5W8Udk
**Arrays & DSA Fundamentals**
- Abdul Bari, full Data Structures & Algorithms playlist: https://www.youtube.com/playlist?list=PLsr8vTgyLdy_YndxNcI4WkH5Vorj5qvrv
**OOP in Python**
- Corey Schafer, Classes and Instances: https://www.youtube.com/watch?v=ZDa-Z5JzLYM
- Full Python OOP playlist: https://www.youtube.com/playlist?list=PL-osiE80TeTsqhIuOqKhwlXsIBIdSeYtc
**OOP in C++**
- freeCodeCamp (taught by CodeBeauty), Object Oriented Programming in C++: https://www.youtube.com/watch?v=wN0x9eZLix4
Feel free to study from any resources that you may find useful. Also give **[Apna College](https://www.youtube.com/@ApnaCollegeOfficial/playlists?themeRefresh=1)** a shot
## How to Submit
1. Pull the latest `main`
2. Create a branch: `git checkout -b dsa/1-two-sum-`
3. Create your folder if you don't have one yet: `DSA//`
4. Add your solution as `DSA//1.py` (or `1.cpp`)
5. Test it locally against the examples in `DSA/problems/1.py`
6. Commit: `git commit -m "Add solution for 1-two-sum"`
7. Push and open a PR against `main`. Link this issue in the PR description (e.g. `Refs #`)
## Checklist
- [ ] Read `DSA/problems/1.py`
- [ ] Reviewed at least the hash map and OOP resources above
- [ ] Solution added at `DSA//1.py`
- [ ] Tested locally
- [ ] PR opened and linked to this issue
---
Everyone in the group is expected to attempt this one. If you get stuck, comment here instead of going quiet, someone will jump in to help.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.