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.4 KiB
2.4 KiB
| 1 | ID | Title | Acceptance | Difficulty | Frequency | Leetcode Question Link |
|---|---|---|---|---|---|---|
| 2 | 740 | Delete and Earn | 48.6% | Medium | 2.0469337965260492 | https://leetcode.com/problems/delete-and-earn |
| 3 | 366 | Find Leaves of Binary Tree | 70.6% | Medium | 1.492934381312693 | https://leetcode.com/problems/find-leaves-of-binary-tree |
| 4 | 547 | Friend Circles | 58.6% | Medium | 0.9389349660993366 | https://leetcode.com/problems/friend-circles |
| 5 | 1010 | Pairs of Songs With Total Durations Divisible by 60 | 47.4% | Easy | 0.8080712743639388 | https://leetcode.com/problems/pairs-of-songs-with-total-durations-divisible-by-60 |
| 6 | 41 | First Missing Positive | 32.0% | Hard | 0.5197501329149874 | https://leetcode.com/problems/first-missing-positive |
| 7 | 28 | Implement strStr() | 34.5% | Easy | 0.49430861720878383 | https://leetcode.com/problems/implement-strstr |
| 8 | 133 | Clone Graph | 34.8% | Medium | 0.4466221331933528 | https://leetcode.com/problems/clone-graph |
| 9 | 75 | Sort Colors | 47.3% | Medium | 0.4245095320511369 | https://leetcode.com/problems/sort-colors |
| 10 | 285 | Inorder Successor in BST | 40.4% | Medium | 0.36133895646771014 | https://leetcode.com/problems/inorder-successor-in-bst |
| 11 | 10 | Regular Expression Matching | 26.8% | Hard | 0.15934409022264243 | https://leetcode.com/problems/regular-expression-matching |
| 12 | 214 | Shortest Palindrome | 29.8% | Hard | 0.07220456924739427 | https://leetcode.com/problems/shortest-palindrome |
| 13 | 347 | Top K Frequent Elements | 61.2% | Medium | 0.05152828440155634 | https://leetcode.com/problems/top-k-frequent-elements |
| 14 | 139 | Word Break | 40.1% | Medium | 0.03329941406904932 | https://leetcode.com/problems/word-break |
| 15 | 269 | Alien Dictionary | 33.3% | Hard | 0.027110094009475887 | https://leetcode.com/problems/alien-dictionary |
| 16 | 215 | Kth Largest Element in an Array | 55.4% | Medium | 0.00838696557248326 | https://leetcode.com/problems/kth-largest-element-in-an-array |
| 17 | 772 | Basic Calculator III | 41.3% | Hard | 0 | https://leetcode.com/problems/basic-calculator-iii |
| 18 | 442 | Find All Duplicates in an Array | 67.8% | Medium | 0 | https://leetcode.com/problems/find-all-duplicates-in-an-array |
| 19 | 380 | Insert Delete GetRandom O(1) | 47.5% | Medium | 0 | https://leetcode.com/problems/insert-delete-getrandom-o1 |
| 20 | 424 | Longest Repeating Character Replacement | 47.0% | Medium | 0 | https://leetcode.com/problems/longest-repeating-character-replacement |
| 21 | 600 | Non-negative Integers without Consecutive Ones | 34.1% | Hard | 0 | https://leetcode.com/problems/non-negative-integers-without-consecutive-ones |
| 22 | 692 | Top K Frequent Words | 51.8% | Medium | 0 | https://leetcode.com/problems/top-k-frequent-words |