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)
```
26 lines
2.6 KiB
CSV
26 lines
2.6 KiB
CSV
ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link
|
|
72,Edit Distance,44.8%,Hard,0.8278420197119241, https://leetcode.com/problems/edit-distance
|
|
271,Encode and Decode Strings,31.5%,Medium,0.6492888646599129, https://leetcode.com/problems/encode-and-decode-strings
|
|
969,Pancake Sorting,67.5%,Medium,0.5905780135393897, https://leetcode.com/problems/pancake-sorting
|
|
336,Palindrome Pairs,33.7%,Hard,0.5700227742957876, https://leetcode.com/problems/palindrome-pairs
|
|
999,Available Captures for Rook,66.7%,Easy,0.4868470419092762, https://leetcode.com/problems/available-captures-for-rook
|
|
91,Decode Ways,24.7%,Medium,0.32434096851350985, https://leetcode.com/problems/decode-ways
|
|
269,Alien Dictionary,33.3%,Hard,0.14578781346149866, https://leetcode.com/problems/alien-dictionary
|
|
273,Integer to English Words,27.1%,Hard,0.10380963271229693, https://leetcode.com/problems/integer-to-english-words
|
|
165,Compare Version Numbers,27.4%,Medium,0.09483978737982436, https://leetcode.com/problems/compare-version-numbers
|
|
415,Add Strings,47.5%,Easy,0.08919862525832246, https://leetcode.com/problems/add-strings
|
|
17,Letter Combinations of a Phone Number,46.8%,Medium,0.0855673732620712, https://leetcode.com/problems/letter-combinations-of-a-phone-number
|
|
277,Find the Celebrity,41.8%,Medium,0.06562120535847293, https://leetcode.com/problems/find-the-celebrity
|
|
208,Implement Trie (Prefix Tree),49.4%,Medium,0.05559457257530485, https://leetcode.com/problems/implement-trie-prefix-tree
|
|
127,Word Ladder,29.6%,Medium,0.05256684589504119, https://leetcode.com/problems/word-ladder
|
|
105,Construct Binary Tree from Preorder and Inorder Traversal,48.8%,Medium,0.049549146900389536, https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal
|
|
824,Goat Latin,63.4%,Easy,0.0317991816929387, https://leetcode.com/problems/goat-latin
|
|
332,Reconstruct Itinerary,36.7%,Medium,0.030687713231237448, https://leetcode.com/problems/reconstruct-itinerary
|
|
981,Time Based Key-Value Store,53.1%,Medium,0.02226024024151985, https://leetcode.com/problems/time-based-key-value-store
|
|
15,3Sum,26.8%,Medium,0.013665148419080968, https://leetcode.com/problems/3sum
|
|
200,Number of Islands,46.8%,Medium,0.011509262420590827, https://leetcode.com/problems/number-of-islands
|
|
139,Word Break,40.1%,Medium,0.008741314401573542, https://leetcode.com/problems/word-break
|
|
39,Combination Sum,56.1%,Medium,0.005715934396440999, https://leetcode.com/problems/combination-sum
|
|
573,Squirrel Simulation,55.6%,Medium,0, https://leetcode.com/problems/squirrel-simulation
|
|
699,Falling Squares,41.8%,Hard,0, https://leetcode.com/problems/falling-squares
|