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)
```
29 lines
3.1 KiB
CSV
29 lines
3.1 KiB
CSV
ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link
|
|
695,Max Area of Island,62.7%,Medium,0.20952332409775687, https://leetcode.com/problems/max-area-of-island
|
|
127,Word Ladder,29.6%,Medium,0.1667080439422554, https://leetcode.com/problems/word-ladder
|
|
42,Trapping Rain Water,48.9%,Hard,0.12389276378675394, https://leetcode.com/problems/trapping-rain-water
|
|
1041,Robot Bounded In Circle,49.6%,Medium,0.10573219378884732, https://leetcode.com/problems/robot-bounded-in-circle
|
|
200,Number of Islands,46.8%,Medium,0.09910455319823885, https://leetcode.com/problems/number-of-islands
|
|
449,Serialize and Deserialize BST,52.0%,Medium,0.08696405427235052, https://leetcode.com/problems/serialize-and-deserialize-bst
|
|
139,Word Break,40.1%,Medium,0.07605014611885268, https://leetcode.com/problems/word-break
|
|
173,Binary Search Tree Iterator,56.6%,Medium,0.07392527369701565, https://leetcode.com/problems/binary-search-tree-iterator
|
|
103,Binary Tree Zigzag Level Order Traversal,48.3%,Medium,0.0697534935244004, https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal
|
|
138,Copy List with Random Pointer,36.4%,Medium,0.05438585262874796, https://leetcode.com/problems/copy-list-with-random-pointer
|
|
13,Roman to Integer,55.7%,Easy,0.04121346863130292, https://leetcode.com/problems/roman-to-integer
|
|
722,Remove Comments,34.6%,Medium,0.04049136135473691, https://leetcode.com/problems/remove-comments
|
|
729,My Calendar I,51.8%,Medium,0.036433902246102004, https://leetcode.com/problems/my-calendar-i
|
|
332,Reconstruct Itinerary,36.7%,Medium,0.030687713231237448, https://leetcode.com/problems/reconstruct-itinerary
|
|
119,Pascal's Triangle II,49.0%,Easy,0.026565907037593445, https://leetcode.com/problems/pascals-triangle-ii
|
|
733,Flood Fill,55.3%,Easy,0.02506396866321625, https://leetcode.com/problems/flood-fill
|
|
131,Palindrome Partitioning,47.5%,Medium,0.013903595538577326, https://leetcode.com/problems/palindrome-partitioning
|
|
767,Reorganize String,48.7%,Medium,0.01329806830463147, https://leetcode.com/problems/reorganize-string
|
|
208,Implement Trie (Prefix Tree),49.4%,Medium,0.009105457856626612, https://leetcode.com/problems/implement-trie-prefix-tree
|
|
295,Find Median from Data Stream,44.3%,Hard,0.00899893586856953, https://leetcode.com/problems/find-median-from-data-stream
|
|
238,Product of Array Except Self,60.1%,Medium,0.008821856860216758, https://leetcode.com/problems/product-of-array-except-self
|
|
15,3Sum,26.8%,Medium,0.00876717944353383, https://leetcode.com/problems/3sum
|
|
297,Serialize and Deserialize Binary Tree,47.5%,Hard,0.007077170374085099, https://leetcode.com/problems/serialize-and-deserialize-binary-tree
|
|
543,Diameter of Binary Tree,48.4%,Easy,0.005305755914149804, https://leetcode.com/problems/diameter-of-binary-tree
|
|
69,Sqrt(x),33.9%,Easy,0.005102051883895465, https://leetcode.com/problems/sqrtx
|
|
34,Find First and Last Position of Element in Sorted Array,36.2%,Medium,0.004247643638268045, https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array
|
|
49,Group Anagrams,56.9%,Medium,0.0038040939835560453, https://leetcode.com/problems/group-anagrams
|