mirror of
https://github.com/krishnadey30/LeetCode-Questions-CompanyWise.git
synced 2025-12-28 05:34:42 +00:00
## Description
- Add headers to all the CSV files
## Script used
```py
import csv
import os
# Set the path of the folder containing the CSV files
folder_path = "./LeetCode-Questions-CompanyWise"
headers = [
"ID",
"Title",
"Acceptance",
"Difficulty",
"Frequency",
"Leetcode Question Link",
]
# Loop through all the CSV files in the folder
for file_name in os.listdir(folder_path):
if file_name.endswith(".csv"):
# Read the CSV file into a list of rows
file_path = os.path.join(folder_path, file_name)
with open(file_path, "r") as f:
reader = csv.reader(f)
rows = list(reader)
has_headers = False
if len(rows) > 0 and rows[0] == headers:
has_headers = True
if not has_headers:
rows.insert(0, headers)
# Write the list of rows back to the CSV file
with open(file_path, "w", newline="") as f:
writer = csv.writer(f)
writer.writerows(rows)
```
1.7 KiB
1.7 KiB
| 1 | ID | Title | Acceptance | Difficulty | Frequency | Leetcode Question Link |
|---|---|---|---|---|---|---|
| 2 | 609 | Find Duplicate File in System | 59.5% | Medium | 4.308646054568235 | https://leetcode.com/problems/find-duplicate-file-in-system |
| 3 | 924 | Minimize Malware Spread | 42.0% | Hard | 3.7034072588050604 | https://leetcode.com/problems/minimize-malware-spread |
| 4 | 289 | Game of Life | 54.5% | Medium | 3.452499696999781 | https://leetcode.com/problems/game-of-life |
| 5 | 379 | Design Phone Directory | 46.8% | Medium | 2.546315277916644 | https://leetcode.com/problems/design-phone-directory |
| 6 | 928 | Minimize Malware Spread II | 40.5% | Hard | 1.6401308588335066 | https://leetcode.com/problems/minimize-malware-spread-ii |
| 7 | 1242 | Web Crawler Multithreaded | 45.9% | Medium | 0.8967461358011848 | https://leetcode.com/problems/web-crawler-multithreaded |
| 8 | 1178 | Number of Valid Words for Each Puzzle | 37.8% | Hard | 0.8109302162163288 | https://leetcode.com/problems/number-of-valid-words-for-each-puzzle |
| 9 | 642 | Design Search Autocomplete System | 44.7% | Hard | 0.43349242036282026 | https://leetcode.com/problems/design-search-autocomplete-system |
| 10 | 146 | LRU Cache | 33.2% | Medium | 0.13057313078965735 | https://leetcode.com/problems/lru-cache |
| 11 | 1010 | Pairs of Songs With Total Durations Divisible by 60 | 47.4% | Easy | 0.09171392769013605 | https://leetcode.com/problems/pairs-of-songs-with-total-durations-divisible-by-60 |
| 12 | 362 | Design Hit Counter | 63.7% | Medium | 0.05622967649867821 | https://leetcode.com/problems/design-hit-counter |
| 13 | 17 | Letter Combinations of a Phone Number | 46.8% | Medium | 0.017492519932499718 | https://leetcode.com/problems/letter-combinations-of-a-phone-number |
| 14 | 64 | Minimum Path Sum | 54.5% | Medium | 0.013734383449598314 | https://leetcode.com/problems/minimum-path-sum |
| 15 | 28 | Implement strStr() | 34.5% | Easy | 0.003943222775040032 | https://leetcode.com/problems/implement-strstr |