mirror of
https://github.com/McSmog/LeetCode-Questions-CompanyWise.git
synced 2026-04-19 16:56:45 +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)
```
2.1 KiB
2.1 KiB
| 1 | ID | Title | Acceptance | Difficulty | Frequency | Leetcode Question Link |
|---|---|---|---|---|---|---|
| 2 | 487 | Max Consecutive Ones II | 48.5% | Medium | 0.03644483834479416 | https://leetcode.com/problems/max-consecutive-ones-ii |
| 3 | 281 | Zigzag Iterator | 58.4% | Medium | 0.034926034605810494 | https://leetcode.com/problems/zigzag-iterator |
| 4 | 283 | Move Zeroes | 57.8% | Easy | 0.024557850781664083 | https://leetcode.com/problems/move-zeroes |
| 5 | 567 | Permutation in String | 44.4% | Medium | 0.014189666957517671 | https://leetcode.com/problems/permutation-in-string |
| 6 | 150 | Evaluate Reverse Polish Notation | 36.3% | Medium | 0.01355493475171521 | https://leetcode.com/problems/evaluate-reverse-polish-notation |
| 7 | 56 | Merge Intervals | 39.3% | Medium | 0.013186279740090647 | https://leetcode.com/problems/merge-intervals |
| 8 | 380 | Insert Delete GetRandom O(1) | 47.5% | Medium | 0.00934149716911291 | https://leetcode.com/problems/insert-delete-getrandom-o1 |
| 9 | 279 | Perfect Squares | 47.4% | Medium | 0.008781615160384712 | https://leetcode.com/problems/perfect-squares |
| 10 | 98 | Validate Binary Search Tree | 27.8% | Medium | 0.0063060747091605324 | https://leetcode.com/problems/validate-binary-search-tree |
| 11 | 21 | Merge Two Sorted Lists | 53.5% | Easy | 0.004849147433009811 | https://leetcode.com/problems/merge-two-sorted-lists |
| 12 | 146 | LRU Cache | 33.2% | Medium | 0.004370636328108912 | https://leetcode.com/problems/lru-cache |
| 13 | 22 | Generate Parentheses | 62.7% | Medium | 0.004152398782798953 | https://leetcode.com/problems/generate-parentheses |
| 14 | 125 | Valid Palindrome | 36.7% | Easy | 0.0037979536727587773 | https://leetcode.com/problems/valid-palindrome |
| 15 | 49 | Group Anagrams | 56.9% | Medium | 0.0036347154963361594 | https://leetcode.com/problems/group-anagrams |
| 16 | 33 | Search in Rotated Sorted Array | 34.5% | Medium | 0.0031000567336666443 | https://leetcode.com/problems/search-in-rotated-sorted-array |
| 17 | 88 | Merge Sorted Array | 39.4% | Easy | 0.002885588497720344 | https://leetcode.com/problems/merge-sorted-array |
| 18 | 206 | Reverse Linked List | 62.5% | Easy | 0.002231770161393673 | https://leetcode.com/problems/reverse-linked-list |
| 19 | 3 | Longest Substring Without Repeating Characters | 30.4% | Medium | 0.0014852223137141987 | https://leetcode.com/problems/longest-substring-without-repeating-characters |