Skip to content

Commit 2b2ee58

Browse files
authored
Create README.md
1 parent 03e7459 commit 2b2ee58

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

day-28/README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Day 28
2+
3+
## ⭐️ Longest Common Prefix – 28.1
4+
### 🔗 Problem
5+
[LeetCode #14 – Longest Common Prefix](https://leetcode.com/problems/longest-common-prefix/)
6+
7+
### 🧠 Core Idea
8+
Choose the first word as a baseline and compare its characters across all other words, stopping when a mismatch is found or one of the words ends.
9+
The substring up to that point is the longest common prefix.
10+
This ensures we only check as far as characters match, giving an efficient early termination strategy.
11+
12+
### 📊 Example
13+
Input: strs = \["flower","flow","flight"]
14+
15+
Output: `"fl"`
16+
17+
### ⏱️ Complexity
18+
- Time: O(S) – where S is the total number of characters across all strings (early exit possible)
19+
20+
- Space: O(1) – Constant space usage
21+
22+
👉 See full code in [longest_common_prefix.py](https://github.com/lyushher/LeetCode-Python-Easy-DSA/blob/main/day-28/longest_common_prefix.py)
23+
24+
---
25+
26+
## ⭐️ Keyboard Row – 28.2
27+
### 🔗 Problem
28+
[LeetCode #500 – Keyboard Row](https://leetcode.com/problems/keyboard-row/)
29+
30+
### 🧠 Core Idea
31+
Each keyboard row can be represented as a set of letters.
32+
For each word, convert its letters into a set and check if it is a subset of any row set.
33+
If yes, the word can be typed using letters from one row only.
34+
35+
### 📊 Example
36+
Input: words = \["Hello","Alaska","Dad","Peace"]
37+
38+
Output: \["Alaska","Dad"]
39+
40+
### ⏱️ Complexity
41+
- Time: O(n·k) – n = number of words, k = average length of each word
42+
43+
- Space: O(1) – Only three row sets used
44+
45+
👉 See full code in [keyboard_row.py](https://github.com/lyushher/LeetCode-Python-Easy-DSA/blob/main/day-28/keyboard_row.py)

0 commit comments

Comments
 (0)