mirror of
https://github.com/krishnadey30/LeetCode-Questions-CompanyWise.git
synced 2025-12-28 13:41: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.8 KiB
1.8 KiB
| 1 | ID | Title | Acceptance | Difficulty | Frequency | Leetcode Question Link |
|---|---|---|---|---|---|---|
| 2 | 770 | Basic Calculator IV | 48.1% | Hard | 0.8056669695056433 | https://leetcode.com/problems/basic-calculator-iv |
| 3 | 811 | Subdomain Visit Count | 69.9% | Easy | 0.6153565614064571 | https://leetcode.com/problems/subdomain-visit-count |
| 4 | 224 | Basic Calculator | 36.8% | Hard | 0.42504615330727086 | https://leetcode.com/problems/basic-calculator |
| 5 | 829 | Consecutive Numbers Sum | 37.5% | Hard | 0.29485791052185223 | https://leetcode.com/problems/consecutive-numbers-sum |
| 6 | 1163 | Last Substring in Lexicographical Order | 33.9% | Hard | 0.1912843449600571 | https://leetcode.com/problems/last-substring-in-lexicographical-order |
| 7 | 1297 | Maximum Number of Occurrences of a Substring | 47.3% | Medium | 0.1670540846631662 | https://leetcode.com/problems/maximum-number-of-occurrences-of-a-substring |
| 8 | 1328 | Break a Palindrome | 43.3% | Medium | 0.12838116664820678 | https://leetcode.com/problems/break-a-palindrome |
| 9 | 1248 | Count Number of Nice Subarrays | 56.4% | Medium | 0.04593229889743518 | https://leetcode.com/problems/count-number-of-nice-subarrays |
| 10 | 146 | LRU Cache | 33.2% | Medium | 0.028411001832779885 | https://leetcode.com/problems/lru-cache |
| 11 | 1290 | Convert Binary Number in a Linked List to Integer | 80.4% | Easy | 0.023623145763435913 | https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer |
| 12 | 37 | Sudoku Solver | 43.6% | Hard | 0.01821543989134118 | https://leetcode.com/problems/sudoku-solver |
| 13 | 239 | Sliding Window Maximum | 43.0% | Hard | 0.01768566434627554 | https://leetcode.com/problems/sliding-window-maximum |
| 14 | 36 | Valid Sudoku | 48.7% | Medium | 0.01625758350956095 | https://leetcode.com/problems/valid-sudoku |
| 15 | 17 | Letter Combinations of a Phone Number | 46.8% | Medium | 0.0044018999217624675 | https://leetcode.com/problems/letter-combinations-of-a-phone-number |
| 16 | 200 | Number of Islands | 46.8% | Medium | 0.0028897578265903614 | https://leetcode.com/problems/number-of-islands |