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)
```
23 lines
2.4 KiB
CSV
23 lines
2.4 KiB
CSV
ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link
|
|
599,Minimum Index Sum of Two Lists,50.7%,Easy,0.4762677241497535, https://leetcode.com/problems/minimum-index-sum-of-two-lists
|
|
355,Design Twitter,30.3%,Medium,0.4013575056633937, https://leetcode.com/problems/design-twitter
|
|
1126,Active Businesses,68.5%,Medium,0.3208150073042144, https://leetcode.com/problems/active-businesses
|
|
692,Top K Frequent Words,51.8%,Medium,0.24027250894503516, https://leetcode.com/problems/top-k-frequent-words
|
|
564,Find the Closest Palindrome,19.7%,Hard,0.18012616623051897, https://leetcode.com/problems/find-the-closest-palindrome
|
|
347,Top K Frequent Elements,61.2%,Medium,0.1517903074513627, https://leetcode.com/problems/top-k-frequent-elements
|
|
528,Random Pick with Weight,43.9%,Medium,0.12617342152539626, https://leetcode.com/problems/random-pick-with-weight
|
|
192,Word Frequency,25.8%,Medium,0.10186917331721722, https://leetcode.com/problems/word-frequency
|
|
332,Reconstruct Itinerary,36.7%,Medium,0.08302143328026106, https://leetcode.com/problems/reconstruct-itinerary
|
|
253,Meeting Rooms II,45.7%,Medium,0.04945628059066218, https://leetcode.com/problems/meeting-rooms-ii
|
|
56,Merge Intervals,39.3%,Medium,0.030829638084076787, https://leetcode.com/problems/merge-intervals
|
|
273,Integer to English Words,27.1%,Hard,0.026980053764546055, https://leetcode.com/problems/integer-to-english-words
|
|
205,Isomorphic Strings,39.8%,Easy,0.011544139746865315, https://leetcode.com/problems/isomorphic-strings
|
|
380,Insert Delete GetRandom O(1),47.5%,Medium,0.009820849864094454, https://leetcode.com/problems/insert-delete-getrandom-o1
|
|
139,Word Break,40.1%,Medium,0.008741314401573542, https://leetcode.com/problems/word-break
|
|
239,Sliding Window Maximum,43.0%,Hard,0.007898935224534491, https://leetcode.com/problems/sliding-window-maximum
|
|
349,Intersection of Two Arrays,62.5%,Easy,0.00725034896230682, https://leetcode.com/problems/intersection-of-two-arrays
|
|
39,Combination Sum,56.1%,Medium,0.005715934396440999, https://leetcode.com/problems/combination-sum
|
|
22,Generate Parentheses,62.7%,Medium,0.0043611059090124735, https://leetcode.com/problems/generate-parentheses
|
|
14,Longest Common Prefix,35.4%,Easy,0.003320331762984143, https://leetcode.com/problems/longest-common-prefix
|
|
3,Longest Substring Without Repeating Characters,30.4%,Medium,0.0015556336509412823, https://leetcode.com/problems/longest-substring-without-repeating-characters
|