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.9 KiB
1.9 KiB
| 1 | ID | Title | Acceptance | Difficulty | Frequency | Leetcode Question Link |
|---|---|---|---|---|---|---|
| 2 | 286 | Walls and Gates | 54.5% | Medium | 0.045906593198722395 | https://leetcode.com/problems/walls-and-gates |
| 3 | 383 | Ransom Note | 53.1% | Easy | 0.039220713153281295 | https://leetcode.com/problems/ransom-note |
| 4 | 480 | Sliding Window Median | 37.2% | Hard | 0.03373001037669306 | https://leetcode.com/problems/sliding-window-median |
| 5 | 20 | Valid Parentheses | 39.0% | Easy | 0.02782373445001039 | https://leetcode.com/problems/valid-parentheses |
| 6 | 22 | Generate Parentheses | 62.7% | Medium | 0.026949997964496694 | https://leetcode.com/problems/generate-parentheses |
| 7 | 784 | Letter Case Permutation | 64.6% | Medium | 0.02026411791905559 | https://leetcode.com/problems/letter-case-permutation |
| 8 | 128 | Longest Consecutive Sequence | 45.1% | Hard | 0.020252717433212362 | https://leetcode.com/problems/longest-consecutive-sequence |
| 9 | 146 | LRU Cache | 33.2% | Medium | 0.01827577993873683 | https://leetcode.com/problems/lru-cache |
| 10 | 443 | String Compression | 41.3% | Easy | 0.01390843004613198 | https://leetcode.com/problems/string-compression |
| 11 | 206 | Reverse Linked List | 62.5% | Easy | 0.009326794511974934 | https://leetcode.com/problems/reverse-linked-list |
| 12 | 215 | Kth Largest Element in an Array | 55.4% | Medium | 0.008759180089881562 | https://leetcode.com/problems/kth-largest-element-in-an-array |
| 13 | 412 | Fizz Buzz | 62.3% | Easy | 0.007165921026143679 | https://leetcode.com/problems/fizz-buzz |
| 14 | 200 | Number of Islands | 46.8% | Medium | 0.006490251382779317 | https://leetcode.com/problems/number-of-islands |
| 15 | 3 | Longest Substring Without Repeating Characters | 30.4% | Medium | 0.006208067119374334 | https://leetcode.com/problems/longest-substring-without-repeating-characters |
| 16 | 127 | Word Ladder | 29.6% | Medium | 0.005979091056058075 | https://leetcode.com/problems/word-ladder |
| 17 | 347 | Top K Frequent Elements | 61.2% | Medium | 0.0033396446491217604 | https://leetcode.com/problems/top-k-frequent-elements |
| 18 | 66 | Plus One | 43.0% | Easy | 0.00326211347832938 | https://leetcode.com/problems/plus-one |
| 19 | 1 | Two Sum | 45.6% | Easy | 0.00184543512358731 | https://leetcode.com/problems/two-sum |