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.6 KiB
1.6 KiB
| 1 | ID | Title | Acceptance | Difficulty | Frequency | Leetcode Question Link |
|---|---|---|---|---|---|---|
| 2 | 761 | Special Binary String | 54.7% | Hard | 0.09348775380846833 | https://leetcode.com/problems/special-binary-string |
| 3 | 362 | Design Hit Counter | 63.7% | Medium | 0.05622967649867821 | https://leetcode.com/problems/design-hit-counter |
| 4 | 1353 | Maximum Number of Events That Can Be Attended | 30.5% | Medium | 0.05428741283782842 | https://leetcode.com/problems/maximum-number-of-events-that-can-be-attended |
| 5 | 42 | Trapping Rain Water | 48.9% | Hard | 0.05203424501747888 | https://leetcode.com/problems/trapping-rain-water |
| 6 | 54 | Spiral Matrix | 34.1% | Medium | 0.014776167707688753 | https://leetcode.com/problems/spiral-matrix |
| 7 | 76 | Minimum Window Substring | 34.6% | Hard | 0.013966707481708198 | https://leetcode.com/problems/minimum-window-substring |
| 8 | 380 | Insert Delete GetRandom O(1) | 47.5% | Medium | 0.009820849864094454 | https://leetcode.com/problems/insert-delete-getrandom-o1 |
| 9 | 253 | Meeting Rooms II | 45.7% | Medium | 0.008079219870546493 | https://leetcode.com/problems/meeting-rooms-ii |
| 10 | 98 | Validate Binary Search Tree | 27.8% | Medium | 0.006611351489350257 | https://leetcode.com/problems/validate-binary-search-tree |
| 11 | 15 | 3Sum | 26.8% | Medium | 0.004940992758742591 | https://leetcode.com/problems/3sum |
| 12 | 121 | Best Time to Buy and Sell Stock | 50.5% | Easy | 0.0047725193990346675 | https://leetcode.com/problems/best-time-to-buy-and-sell-stock |
| 13 | 1 | Two Sum | 45.6% | Easy | 0.003278422738041615 | https://leetcode.com/problems/two-sum |
| 14 | 206 | Reverse Linked List | 62.5% | Easy | 0.0023398665252948926 | https://leetcode.com/problems/reverse-linked-list |
| 15 | 20 | Valid Parentheses | 39.0% | Easy | 0.0023005704055949323 | https://leetcode.com/problems/valid-parentheses |