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)
```
27 lines
2.8 KiB
CSV
27 lines
2.8 KiB
CSV
ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link
|
|
312,Burst Balloons,51.8%,Hard,0.1436030350715959, https://leetcode.com/problems/burst-balloons
|
|
1,Two Sum,45.6%,Easy,0.10724153306109706, https://leetcode.com/problems/two-sum
|
|
572,Subtree of Another Tree,44.1%,Easy,0.08694829147719678, https://leetcode.com/problems/subtree-of-another-tree
|
|
31,Next Permutation,32.6%,Medium,0.05058678946669793, https://leetcode.com/problems/next-permutation
|
|
85,Maximal Rectangle,37.7%,Hard,0.050135812424355455, https://leetcode.com/problems/maximal-rectangle
|
|
20,Valid Parentheses,39.0%,Easy,0.04358808999497224, https://leetcode.com/problems/valid-parentheses
|
|
32,Longest Valid Parentheses,28.4%,Hard,0.03477099521294092, https://leetcode.com/problems/longest-valid-parentheses
|
|
15,3Sum,26.8%,Medium,0.03278982282299087, https://leetcode.com/problems/3sum
|
|
18,4Sum,33.7%,Medium,0.02090668481931367, https://leetcode.com/problems/4sum
|
|
33,Search in Rotated Sorted Array,34.5%,Medium,0.019219533793635182, https://leetcode.com/problems/search-in-rotated-sorted-array
|
|
22,Generate Parentheses,62.7%,Medium,0.016507132273019587, https://leetcode.com/problems/generate-parentheses
|
|
876,Middle of the Linked List,68.4%,Easy,0.01631061893137506, https://leetcode.com/problems/middle-of-the-linked-list
|
|
5,Longest Palindromic Substring,29.5%,Medium,0.013529809159515602, https://leetcode.com/problems/longest-palindromic-substring
|
|
3,Longest Substring Without Repeating Characters,30.4%,Medium,0.013288251045064422, https://leetcode.com/problems/longest-substring-without-repeating-characters
|
|
523,Continuous Subarray Sum,24.6%,Medium,0.011293174793455513, https://leetcode.com/problems/continuous-subarray-sum
|
|
103,Binary Tree Zigzag Level Order Traversal,48.3%,Medium,0.010504298266876018, https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal
|
|
190,Reverse Bits,39.8%,Easy,0.007245095991891571, https://leetcode.com/problems/reverse-bits
|
|
127,Word Ladder,29.6%,Medium,0.005731495844689608, https://leetcode.com/problems/word-ladder
|
|
21,Merge Two Sorted Lists,53.5%,Easy,0.004849147433009811, https://leetcode.com/problems/merge-two-sorted-lists
|
|
653,Two Sum IV - Input is a BST,55.5%,Easy,0, https://leetcode.com/problems/two-sum-iv-input-is-a-bst
|
|
987,Vertical Order Traversal of a Binary Tree,36.6%,Medium,0, https://leetcode.com/problems/vertical-order-traversal-of-a-binary-tree
|
|
1301,Number of Paths with Max Score,37.3%,Hard,0, https://leetcode.com/problems/number-of-paths-with-max-score
|
|
1139,Largest 1-Bordered Square,47.5%,Medium,0, https://leetcode.com/problems/largest-1-bordered-square
|
|
1464,Maximum Product of Two Elements in an Array,78.1%,Easy,0, https://leetcode.com/problems/maximum-product-of-two-elements-in-an-array
|
|
1519,Number of Nodes in the Sub-Tree With the Same Label,35.2%,Medium,0, https://leetcode.com/problems/number-of-nodes-in-the-sub-tree-with-the-same-label
|