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)
```
2.8 KiB
2.8 KiB
| 1 | ID | Title | Acceptance | Difficulty | Frequency | Leetcode Question Link |
|---|---|---|---|---|---|---|
| 2 | 256 | Paint House | 52.1% | Easy | 0.03172360722570897 | https://leetcode.com/problems/paint-house |
| 3 | 143 | Reorder List | 37.1% | Medium | 0.025870945598649286 | https://leetcode.com/problems/reorder-list |
| 4 | 33 | Search in Rotated Sorted Array | 34.5% | Medium | 0.0200182839715896 | https://leetcode.com/problems/search-in-rotated-sorted-array |
| 5 | 1143 | Longest Common Subsequence | 58.4% | Medium | 0.019772173115579716 | https://leetcode.com/problems/longest-common-subsequence |
| 6 | 394 | Decode String | 50.0% | Medium | 0.0182820448374491 | https://leetcode.com/problems/decode-string |
| 7 | 21 | Merge Two Sorted Lists | 53.5% | Easy | 0.014012111332134735 | https://leetcode.com/problems/merge-two-sorted-lists |
| 8 | 227 | Basic Calculator II | 36.9% | Medium | 0.01239941490503826 | https://leetcode.com/problems/basic-calculator-ii |
| 9 | 543 | Diameter of Binary Tree | 48.4% | Easy | 0.011898606798495848 | https://leetcode.com/problems/diameter-of-binary-tree |
| 10 | 121 | Best Time to Buy and Sell Stock | 50.5% | Easy | 0.00846879565300311 | https://leetcode.com/problems/best-time-to-buy-and-sell-stock |
| 11 | 240 | Search a 2D Matrix II | 43.2% | Medium | 0.0075829747244553335 | https://leetcode.com/problems/search-a-2d-matrix-ii |
| 12 | 136 | Single Number | 65.5% | Easy | 0.006445166968713385 | https://leetcode.com/problems/single-number |
| 13 | 76 | Minimum Window Substring | 34.6% | Hard | 0.006231520398723243 | https://leetcode.com/problems/minimum-window-substring |
| 14 | 287 | Find the Duplicate Number | 55.5% | Medium | 0.005501320434837602 | https://leetcode.com/problems/find-the-duplicate-number |
| 15 | 206 | Reverse Linked List | 62.5% | Easy | 0.005257021452801617 | https://leetcode.com/problems/reverse-linked-list |
| 16 | 15 | 3Sum | 26.8% | Medium | 0.004940992758742591 | https://leetcode.com/problems/3sum |
| 17 | 160 | Intersection of Two Linked Lists | 40.6% | Easy | 0.004901369939720486 | https://leetcode.com/problems/intersection-of-two-linked-lists |
| 18 | 169 | Majority Element | 58.7% | Easy | 0.004706444738837472 | https://leetcode.com/problems/majority-element |
| 19 | 215 | Kth Largest Element in an Array | 55.4% | Medium | 0.003902443976931749 | https://leetcode.com/problems/kth-largest-element-in-an-array |
| 20 | 4 | Median of Two Sorted Arrays | 29.6% | Hard | 0.003900160950094767 | https://leetcode.com/problems/median-of-two-sorted-arrays |
| 21 | 8 | String to Integer (atoi) | 15.4% | Medium | 0.0037925521897059712 | https://leetcode.com/problems/string-to-integer-atoi |
| 22 | 56 | Merge Intervals | 39.3% | Medium | 0.0034728286335985107 | https://leetcode.com/problems/merge-intervals |
| 23 | 1 | Two Sum | 45.6% | Easy | 0.003278422738041615 | https://leetcode.com/problems/two-sum |
| 24 | 20 | Valid Parentheses | 39.0% | Easy | 0.0023005704055949323 | https://leetcode.com/problems/valid-parentheses |
| 25 | 5 | Longest Palindromic Substring | 29.5% | Medium | 0.002279333142507479 | https://leetcode.com/problems/longest-palindromic-substring |
| 26 | 190 | Reverse Bits | 39.8% | Easy | 0.0018316700789167337 | https://leetcode.com/problems/reverse-bits |