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 | 274 | H-Index | 36.1% | Medium | 0.18810197835269699 | https://leetcode.com/problems/h-index |
| 3 | 146 | LRU Cache | 33.2% | Medium | 0.14642426807449366 | https://leetcode.com/problems/lru-cache |
| 4 | 149 | Max Points on a Line | 16.9% | Hard | 0.13811211729480913 | https://leetcode.com/problems/max-points-on-a-line |
| 5 | 1213 | Intersection of Three Sorted Arrays | 78.9% | Easy | 0.09643440701660581 | https://leetcode.com/problems/intersection-of-three-sorted-arrays |
| 6 | 73 | Set Matrix Zeroes | 43.1% | Medium | 0.07912453490203865 | https://leetcode.com/problems/set-matrix-zeroes |
| 7 | 692 | Top K Frequent Words | 51.8% | Medium | 0.06262915907044142 | https://leetcode.com/problems/top-k-frequent-words |
| 8 | 528 | Random Pick with Weight | 43.9% | Medium | 0.056333090457586533 | https://leetcode.com/problems/random-pick-with-weight |
| 9 | 65 | Valid Number | 15.3% | Hard | 0.04813763559815448 | https://leetcode.com/problems/valid-number |
| 10 | 206 | Reverse Linked List | 62.5% | Easy | 0.03512406277610997 | https://leetcode.com/problems/reverse-linked-list |
| 11 | 98 | Validate Binary Search Tree | 27.8% | Medium | 0.033861720512945864 | https://leetcode.com/problems/validate-binary-search-tree |
| 12 | 1002 | Find Common Characters | 67.7% | Easy | 0.033176651317732786 | https://leetcode.com/problems/find-common-characters |
| 13 | 33 | Search in Rotated Sorted Array | 34.5% | Medium | 0.019219533793635182 | https://leetcode.com/problems/search-in-rotated-sorted-array |
| 14 | 384 | Shuffle an Array | 52.8% | Medium | 0.014706147389695468 | https://leetcode.com/problems/shuffle-an-array |
| 15 | 101 | Symmetric Tree | 46.8% | Easy | 0.013003027580387157 | https://leetcode.com/problems/symmetric-tree |
| 16 | 70 | Climbing Stairs | 47.8% | Easy | 0.005888214855949732 | https://leetcode.com/problems/climbing-stairs |
| 17 | 139 | Word Break | 40.1% | Medium | 0.003755167762323698 | https://leetcode.com/problems/word-break |