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)
```
27 lines
2.8 KiB
CSV
27 lines
2.8 KiB
CSV
ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link
|
|
811,Subdomain Visit Count,69.9%,Easy,2.279318755431106, https://leetcode.com/problems/subdomain-visit-count
|
|
228,Summary Ranges,39.5%,Medium,1.7937622738230257, https://leetcode.com/problems/summary-ranges
|
|
224,Basic Calculator,36.8%,Hard,1.5218100126135983, https://leetcode.com/problems/basic-calculator
|
|
770,Basic Calculator IV,48.1%,Hard,1.349926716949016, https://leetcode.com/problems/basic-calculator-iv
|
|
68,Text Justification,27.7%,Hard,0.8643702353409353, https://leetcode.com/problems/text-justification
|
|
718,Maximum Length of Repeated Subarray,49.4%,Medium,0.7106070931884567, https://leetcode.com/problems/maximum-length-of-repeated-subarray
|
|
362,Design Hit Counter,63.7%,Medium,0.49632511075908853, https://leetcode.com/problems/design-hit-counter
|
|
23,Merge k Sorted Lists,40.2%,Hard,0.4603279232190457, https://leetcode.com/problems/merge-k-sorted-lists
|
|
563,Binary Tree Tilt,48.7%,Easy,0.40185220095239377, https://leetcode.com/problems/binary-tree-tilt
|
|
1197,Minimum Knight Moves,36.1%,Medium,0.3142660340639637, https://leetcode.com/problems/minimum-knight-moves
|
|
85,Maximal Rectangle,37.7%,Hard,0.15223129344145475, https://leetcode.com/problems/maximal-rectangle
|
|
346,Moving Average from Data Stream,70.9%,Easy,0.14878873668587292, https://leetcode.com/problems/moving-average-from-data-stream
|
|
21,Merge Two Sorted Lists,53.5%,Easy,0.05490757117845869, https://leetcode.com/problems/merge-two-sorted-lists
|
|
829,Consecutive Numbers Sum,37.5%,Hard,0.05341723749698583, https://leetcode.com/problems/consecutive-numbers-sum
|
|
227,Basic Calculator II,36.9%,Medium,0.04870104158125306, https://leetcode.com/problems/basic-calculator-ii
|
|
380,Insert Delete GetRandom O(1),47.5%,Medium,0.038717635350707984, https://leetcode.com/problems/insert-delete-getrandom-o1
|
|
349,Intersection of Two Arrays,62.5%,Easy,0.028691227482495342, https://leetcode.com/problems/intersection-of-two-arrays
|
|
297,Serialize and Deserialize Binary Tree,47.5%,Hard,0.028013036227673965, https://leetcode.com/problems/serialize-and-deserialize-binary-tree
|
|
1,Two Sum,45.6%,Easy,0.020315992091756507, https://leetcode.com/problems/two-sum
|
|
88,Merge Sorted Array,39.4%,Easy,0.018667009593356397, https://leetcode.com/problems/merge-sorted-array
|
|
724,Find Pivot Index,44.0%,Easy,0.013850636933899008, https://leetcode.com/problems/find-pivot-index
|
|
560,Subarray Sum Equals K,43.9%,Medium,0.009603146783199741, https://leetcode.com/problems/subarray-sum-equals-k
|
|
1143,Longest Common Subsequence,58.4%,Medium,0.008835931134362285, https://leetcode.com/problems/longest-common-subsequence
|
|
453,Minimum Moves to Equal Array Elements,50.2%,Easy,0, https://leetcode.com/problems/minimum-moves-to-equal-array-elements
|
|
985,Sum of Even Numbers After Queries,61.3%,Easy,0, https://leetcode.com/problems/sum-of-even-numbers-after-queries
|