mirror of
https://github.com/McSmog/LeetCode-Questions-CompanyWise.git
synced 2026-04-19 08:46: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.0 KiB
2.0 KiB
| 1 | ID | Title | Acceptance | Difficulty | Frequency | Leetcode Question Link |
|---|---|---|---|---|---|---|
| 2 | 227 | Basic Calculator II | 36.9% | Medium | 0.21141874864915486 | https://leetcode.com/problems/basic-calculator-ii |
| 3 | 727 | Minimum Window Subsequence | 41.8% | Hard | 0.15970111035790735 | https://leetcode.com/problems/minimum-window-subsequence |
| 4 | 304 | Range Sum Query 2D - Immutable | 38.6% | Medium | 0.1583948504722182 | https://leetcode.com/problems/range-sum-query-2d-immutable |
| 5 | 721 | Accounts Merge | 48.8% | Medium | 0.15836350116973763 | https://leetcode.com/problems/accounts-merge |
| 6 | 43 | Multiply Strings | 33.9% | Medium | 0.10664586287849012 | https://leetcode.com/problems/multiply-strings |
| 7 | 218 | The Skyline Problem | 34.6% | Hard | 0.0564413109049518 | https://leetcode.com/problems/the-skyline-problem |
| 8 | 556 | Next Greater Element III | 31.7% | Medium | 0.04679216150675895 | https://leetcode.com/problems/next-greater-element-iii |
| 9 | 200 | Number of Islands | 46.8% | Medium | 0.04526299408355752 | https://leetcode.com/problems/number-of-islands |
| 10 | 48 | Rotate Image | 56.7% | Medium | 0.04495138786226632 | https://leetcode.com/problems/rotate-image |
| 11 | 698 | Partition to K Equal Sum Subsets | 45.0% | Medium | 0.02109782896463587 | https://leetcode.com/problems/partition-to-k-equal-sum-subsets |
| 12 | 301 | Remove Invalid Parentheses | 43.3% | Hard | 0.01446679841775339 | https://leetcode.com/problems/remove-invalid-parentheses |
| 13 | 31 | Next Permutation | 32.6% | Medium | 0.013427025530888667 | https://leetcode.com/problems/next-permutation |
| 14 | 120 | Triangle | 44.2% | Medium | 0.013236460625830901 | https://leetcode.com/problems/triangle |
| 15 | 212 | Word Search II | 34.9% | Hard | 0.009845021678804893 | https://leetcode.com/problems/word-search-ii |
| 16 | 10 | Regular Expression Matching | 26.8% | Hard | 0.0071865203293987245 | https://leetcode.com/problems/regular-expression-matching |
| 17 | 4 | Median of Two Sorted Arrays | 29.6% | Hard | 0.003900160950094767 | https://leetcode.com/problems/median-of-two-sorted-arrays |
| 18 | 660 | Remove 9 | 53.3% | Hard | 0 | https://leetcode.com/problems/remove-9 |
| 19 | 772 | Basic Calculator III | 41.3% | Hard | 0 | https://leetcode.com/problems/basic-calculator-iii |