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)
```
24 lines
2.4 KiB
CSV
24 lines
2.4 KiB
CSV
ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link
|
|
202,Happy Number,50.4%,Easy,3.472501931831341, https://leetcode.com/problems/happy-number
|
|
20,Valid Parentheses,39.0%,Easy,2.091183527592892, https://leetcode.com/problems/valid-parentheses
|
|
322,Coin Change,35.5%,Medium,0.7098651233544434, https://leetcode.com/problems/coin-change
|
|
121,Best Time to Buy and Sell Stock,50.5%,Easy,0.24778819384825912, https://leetcode.com/problems/best-time-to-buy-and-sell-stock
|
|
1328,Break a Palindrome,43.3%,Medium,0.21795507637539235, https://leetcode.com/problems/break-a-palindrome
|
|
31,Next Permutation,32.6%,Medium,0.11480808652664298, https://leetcode.com/problems/next-permutation
|
|
273,Integer to English Words,27.1%,Hard,0.10380963271229693, https://leetcode.com/problems/integer-to-english-words
|
|
9,Palindrome Number,48.4%,Easy,0.08804403243108966, https://leetcode.com/problems/palindrome-number
|
|
1,Two Sum,45.6%,Easy,0.07889903801250679, https://leetcode.com/problems/two-sum
|
|
7,Reverse Integer,25.8%,Easy,0.054824382173728654, https://leetcode.com/problems/reverse-integer
|
|
17,Letter Combinations of a Phone Number,46.8%,Medium,0.052632421620123555, https://leetcode.com/problems/letter-combinations-of-a-phone-number
|
|
200,Number of Islands,46.8%,Medium,0.04526299408355752, https://leetcode.com/problems/number-of-islands
|
|
53,Maximum Subarray,46.5%,Easy,0.04299340685592046, https://leetcode.com/problems/maximum-subarray
|
|
5,Longest Palindromic Substring,29.5%,Medium,0.035860192879893796, https://leetcode.com/problems/longest-palindromic-substring
|
|
4,Median of Two Sorted Arrays,29.6%,Hard,0.034565653112280895, https://leetcode.com/problems/median-of-two-sorted-arrays
|
|
33,Search in Rotated Sorted Array,34.5%,Medium,0.0287009496170278, https://leetcode.com/problems/search-in-rotated-sorted-array
|
|
146,LRU Cache,33.2%,Medium,0.028411001832779885, https://leetcode.com/problems/lru-cache
|
|
349,Intersection of Two Arrays,62.5%,Easy,0.016239981598488416, https://leetcode.com/problems/intersection-of-two-arrays
|
|
79,Word Search,35.6%,Medium,0.014883688014740005, https://leetcode.com/problems/word-search
|
|
215,Kth Largest Element in an Array,55.4%,Medium,0.008759180089881562, https://leetcode.com/problems/kth-largest-element-in-an-array
|
|
39,Combination Sum,56.1%,Medium,0.005715934396440999, https://leetcode.com/problems/combination-sum
|
|
387,First Unique Character in a String,53.4%,Easy,0.00418541994270691, https://leetcode.com/problems/first-unique-character-in-a-string
|