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.9 KiB
1.9 KiB
| 1 | ID | Title | Acceptance | Difficulty | Frequency | Leetcode Question Link |
|---|---|---|---|---|---|---|
| 2 | 695 | Max Area of Island | 62.7% | Medium | 0.09988789637571764 | https://leetcode.com/problems/max-area-of-island |
| 3 | 127 | Word Ladder | 29.6% | Medium | 0.06918942849168566 | https://leetcode.com/problems/word-ladder |
| 4 | 42 | Trapping Rain Water | 48.9% | Hard | 0.038490960607653675 | https://leetcode.com/problems/trapping-rain-water |
| 5 | 729 | My Calendar I | 51.8% | Medium | 0.036433902246102004 | https://leetcode.com/problems/my-calendar-i |
| 6 | 139 | Word Break | 40.1% | Medium | 0.03451593709018879 | https://leetcode.com/problems/word-break |
| 7 | 332 | Reconstruct Itinerary | 36.7% | Medium | 0.030687713231237448 | https://leetcode.com/problems/reconstruct-itinerary |
| 8 | 138 | Copy List with Random Pointer | 36.4% | Medium | 0.02453734514188008 | https://leetcode.com/problems/copy-list-with-random-pointer |
| 9 | 103 | Binary Tree Zigzag Level Order Traversal | 48.3% | Medium | 0.020730076462920684 | https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal |
| 10 | 173 | Binary Search Tree Iterator | 56.6% | Medium | 0.01899993824490396 | https://leetcode.com/problems/binary-search-tree-iterator |
| 11 | 131 | Palindrome Partitioning | 47.5% | Medium | 0.013903595538577326 | https://leetcode.com/problems/palindrome-partitioning |
| 12 | 767 | Reorganize String | 48.7% | Medium | 0.01329806830463147 | https://leetcode.com/problems/reorganize-string |
| 13 | 733 | Flood Fill | 55.3% | Easy | 0.011217167530924988 | https://leetcode.com/problems/flood-fill |
| 14 | 208 | Implement Trie (Prefix Tree) | 49.4% | Medium | 0.009105457856626612 | https://leetcode.com/problems/implement-trie-prefix-tree |
| 15 | 238 | Product of Array Except Self | 60.1% | Medium | 0.008821856860216758 | https://leetcode.com/problems/product-of-array-except-self |
| 16 | 13 | Roman to Integer | 55.7% | Easy | 0.007698267425752388 | https://leetcode.com/problems/roman-to-integer |
| 17 | 200 | Number of Islands | 46.8% | Medium | 0.006490251382779317 | https://leetcode.com/problems/number-of-islands |
| 18 | 15 | 3Sum | 26.8% | Medium | 0.004940992758742591 | https://leetcode.com/problems/3sum |