mirror of
https://github.com/McSmog/LeetCode-Questions-CompanyWise.git
synced 2026-04-19 16:56: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)
```
19 lines
2.0 KiB
CSV
19 lines
2.0 KiB
CSV
ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link
|
|
735,Asteroid Collision,41.0%,Medium,0.4807449678769452, https://leetcode.com/problems/asteroid-collision
|
|
365,Water and Jug Problem,30.6%,Medium,0.36154113358990525, https://leetcode.com/problems/water-and-jug-problem
|
|
981,Time Based Key-Value Store,53.1%,Medium,0.24353082235287765, https://leetcode.com/problems/time-based-key-value-store
|
|
238,Product of Array Except Self,60.1%,Medium,0.22477655808124566, https://leetcode.com/problems/product-of-array-except-self
|
|
158,Read N Characters Given Read4 II - Call multiple times,33.8%,Hard,0.21421194491522716, https://leetcode.com/problems/read-n-characters-given-read4-ii-call-multiple-times
|
|
642,Design Search Autocomplete System,44.7%,Hard,0.09500811062818718, https://leetcode.com/problems/design-search-autocomplete-system
|
|
716,Max Stack,42.6%,Easy,0.09362342046209744, https://leetcode.com/problems/max-stack
|
|
304,Range Sum Query 2D - Immutable,38.6%,Medium,0.054527987071175225, https://leetcode.com/problems/range-sum-query-2d-immutable
|
|
127,Word Ladder,29.6%,Medium,0.03679590970204585, https://leetcode.com/problems/word-ladder
|
|
91,Decode Ways,24.7%,Medium,0.023662742620848144, https://leetcode.com/problems/decode-ways
|
|
567,Permutation in String,44.4%,Medium,0.014947961435873182, https://leetcode.com/problems/permutation-in-string
|
|
109,Convert Sorted List to Binary Search Tree,47.7%,Medium,0.014440684154794336, https://leetcode.com/problems/convert-sorted-list-to-binary-search-tree
|
|
88,Merge Sorted Array,39.4%,Easy,0.006760335218638243, https://leetcode.com/problems/merge-sorted-array
|
|
76,Minimum Window Substring,34.6%,Hard,0.006231520398723243, https://leetcode.com/problems/minimum-window-substring
|
|
17,Letter Combinations of a Phone Number,46.8%,Medium,0.0044018999217624675, https://leetcode.com/problems/letter-combinations-of-a-phone-number
|
|
23,Merge k Sorted Lists,40.2%,Hard,0.004051459000748015, https://leetcode.com/problems/merge-k-sorted-lists
|
|
20,Valid Parentheses,39.0%,Easy,0.0023005704055949323, https://leetcode.com/problems/valid-parentheses
|