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)
```
1.8 KiB
1.8 KiB
| 1 | ID | Title | Acceptance | Difficulty | Frequency | Leetcode Question Link |
|---|---|---|---|---|---|---|
| 2 | 974 | Subarray Sums Divisible by K | 48.9% | Medium | 1.8764428348188085 | https://leetcode.com/problems/subarray-sums-divisible-by-k |
| 3 | 146 | LRU Cache | 33.2% | Medium | 1.1096937929728194 | https://leetcode.com/problems/lru-cache |
| 4 | 935 | Knight Dialer | 45.2% | Medium | 0.3429447511268304 | https://leetcode.com/problems/knight-dialer |
| 5 | 68 | Text Justification | 27.7% | Hard | 0.29518712556880805 | https://leetcode.com/problems/text-justification |
| 6 | 332 | Reconstruct Itinerary | 36.7% | Medium | 0.24722791193435328 | https://leetcode.com/problems/reconstruct-itinerary |
| 7 | 20 | Valid Parentheses | 39.0% | Easy | 0.09286263438126167 | https://leetcode.com/problems/valid-parentheses |
| 8 | 225 | Implement Stack using Queues | 45.1% | Easy | 0.03661922580674248 | https://leetcode.com/problems/implement-stack-using-queues |
| 9 | 560 | Subarray Sum Equals K | 43.9% | Medium | 0.026450970794755804 | https://leetcode.com/problems/subarray-sum-equals-k |
| 10 | 532 | K-diff Pairs in an Array | 31.6% | Easy | 0.018735911057469818 | https://leetcode.com/problems/k-diff-pairs-in-an-array |
| 11 | 139 | Word Break | 40.1% | Medium | 0.015487677691351377 | https://leetcode.com/problems/word-break |
| 12 | 380 | Insert Delete GetRandom O(1) | 47.5% | Medium | 0.009820849864094454 | https://leetcode.com/problems/insert-delete-getrandom-o1 |
| 13 | 49 | Group Anagrams | 56.9% | Medium | 0.008538951314232168 | https://leetcode.com/problems/group-anagrams |
| 14 | 1 | Two Sum | 45.6% | Easy | 0.0051178232035212715 | https://leetcode.com/problems/two-sum |
| 15 | 17 | Letter Combinations of a Phone Number | 46.8% | Medium | 0.0044018999217624675 | https://leetcode.com/problems/letter-combinations-of-a-phone-number |
| 16 | 14 | Longest Common Prefix | 35.4% | Easy | 0.003320331762984143 | https://leetcode.com/problems/longest-common-prefix |
| 17 | 965 | Univalued Binary Tree | 67.7% | Easy | 0 | https://leetcode.com/problems/univalued-binary-tree |
| 18 | 1507 | Reformat Date | 60.5% | Easy | 0 | https://leetcode.com/problems/reformat-date |