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)
```
30 lines
3.2 KiB
CSV
30 lines
3.2 KiB
CSV
ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link
|
|
256,Paint House,52.1%,Easy,0.8299890646199083, https://leetcode.com/problems/paint-house
|
|
780,Reaching Points,29.4%,Hard,0.6779561713749561, https://leetcode.com/problems/reaching-points
|
|
635,Design Log Storage System,58.6%,Medium,0.48162092276953306, https://leetcode.com/problems/design-log-storage-system
|
|
57,Insert Interval,33.5%,Hard,0.28528567416411, https://leetcode.com/problems/insert-interval
|
|
1326,Minimum Number of Taps to Open to Water a Garden,43.6%,Hard,0.2786048543006643, https://leetcode.com/problems/minimum-number-of-taps-to-open-to-water-a-garden
|
|
945,Minimum Increment to Make Array Unique,46.3%,Medium,0.27427904232444056, https://leetcode.com/problems/minimum-increment-to-make-array-unique
|
|
547,Friend Circles,58.6%,Medium,0.22246660738239243, https://leetcode.com/problems/friend-circles
|
|
532,K-diff Pairs in an Array,31.6%,Easy,0.15718558352241233, https://leetcode.com/problems/k-diff-pairs-in-an-array
|
|
647,Palindromic Substrings,60.6%,Medium,0.06329624434241725, https://leetcode.com/problems/palindromic-substrings
|
|
307,Range Sum Query - Mutable,34.6%,Medium,0.04935211978972769, https://leetcode.com/problems/range-sum-query-mutable
|
|
341,Flatten Nested List Iterator,52.9%,Medium,0.04440788848944038, https://leetcode.com/problems/flatten-nested-list-iterator
|
|
716,Max Stack,42.6%,Easy,0.042695919196489414, https://leetcode.com/problems/max-stack
|
|
161,One Edit Distance,32.3%,Medium,0.03626870773745257, https://leetcode.com/problems/one-edit-distance
|
|
528,Random Pick with Weight,43.9%,Medium,0.03306693626657339, https://leetcode.com/problems/random-pick-with-weight
|
|
496,Next Greater Element I,63.8%,Easy,0.029462032730316202, https://leetcode.com/problems/next-greater-element-i
|
|
981,Time Based Key-Value Store,53.1%,Medium,0.02226024024151985, https://leetcode.com/problems/time-based-key-value-store
|
|
540,Single Element in a Sorted Array,57.9%,Medium,0.0192128868599912, https://leetcode.com/problems/single-element-in-a-sorted-array
|
|
239,Sliding Window Maximum,43.0%,Hard,0.01768566434627554, https://leetcode.com/problems/sliding-window-maximum
|
|
706,Design HashMap,61.3%,Easy,0.01752893260576219, https://leetcode.com/problems/design-hashmap
|
|
767,Reorganize String,48.7%,Medium,0.01329806830463147, https://leetcode.com/problems/reorganize-string
|
|
269,Alien Dictionary,33.3%,Hard,0.012730916694039954, https://leetcode.com/problems/alien-dictionary
|
|
23,Merge k Sorted Lists,40.2%,Hard,0.009092808657599025, https://leetcode.com/problems/merge-k-sorted-lists
|
|
10,Regular Expression Matching,26.8%,Hard,0.0071865203293987245, https://leetcode.com/problems/regular-expression-matching
|
|
105,Construct Binary Tree from Preorder and Inorder Traversal,48.8%,Medium,0.005628268691614718, https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal
|
|
139,Word Break,40.1%,Medium,0.003894465052690167, https://leetcode.com/problems/word-break
|
|
56,Merge Intervals,39.3%,Medium,0.0034728286335985107, https://leetcode.com/problems/merge-intervals
|
|
210,Course Schedule II,40.7%,Medium,0.0019086707135282834, https://leetcode.com/problems/course-schedule-ii
|
|
1,Two Sum,45.6%,Easy,0.0008206138651873125, https://leetcode.com/problems/two-sum
|