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.4 KiB
1.4 KiB
| 1 | ID | Title | Acceptance | Difficulty | Frequency | Leetcode Question Link |
|---|---|---|---|---|---|---|
| 2 | 736 | Parse Lisp Expression | 47.5% | Hard | 0.7290367865107017 | https://leetcode.com/problems/parse-lisp-expression |
| 3 | 381 | Insert Delete GetRandom O(1) - Duplicates allowed | 34.1% | Hard | 0.49586980740929654 | https://leetcode.com/problems/insert-delete-getrandom-o1-duplicates-allowed |
| 4 | 695 | Max Area of Island | 62.7% | Medium | 0.31425595727716876 | https://leetcode.com/problems/max-area-of-island |
| 5 | 380 | Insert Delete GetRandom O(1) | 47.5% | Medium | 0.08108897817576358 | https://leetcode.com/problems/insert-delete-getrandom-o1 |
| 6 | 49 | Group Anagrams | 56.9% | Medium | 0.05662724563684648 | https://leetcode.com/problems/group-anagrams |
| 7 | 200 | Number of Islands | 46.8% | Medium | 0.033359117749874545 | https://leetcode.com/problems/number-of-islands |
| 8 | 362 | Design Hit Counter | 63.7% | Medium | 0.024317307650706343 | https://leetcode.com/problems/design-hit-counter |
| 9 | 322 | Coin Change | 35.5% | Medium | 0.008671409957551127 | https://leetcode.com/problems/coin-change |
| 10 | 230 | Kth Smallest Element in a BST | 60.2% | Medium | 0.006085520073802784 | https://leetcode.com/problems/kth-smallest-element-in-a-bst |
| 11 | 127 | Word Ladder | 29.6% | Medium | 0.005731495844689608 | https://leetcode.com/problems/word-ladder |
| 12 | 42 | Trapping Rain Water | 48.9% | Hard | 0.00411947029523883 | https://leetcode.com/problems/trapping-rain-water |
| 13 | 1 | Two Sum | 45.6% | Easy | 0.003139596786381058 | https://leetcode.com/problems/two-sum |