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)
```
24 lines
2.7 KiB
CSV
24 lines
2.7 KiB
CSV
ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link
|
|
1071,Greatest Common Divisor of Strings,52.9%,Easy,0.11954237676819192, https://leetcode.com/problems/greatest-common-divisor-of-strings
|
|
366,Find Leaves of Binary Tree,70.6%,Medium,0.1180240366638968, https://leetcode.com/problems/find-leaves-of-binary-tree
|
|
1223,Dice Roll Simulation,45.6%,Medium,0.10212949507637983, https://leetcode.com/problems/dice-roll-simulation
|
|
362,Design Hit Counter,63.7%,Medium,0.09787757530957068, https://leetcode.com/problems/design-hit-counter
|
|
981,Time Based Key-Value Store,53.1%,Medium,0.08621383525234454, https://leetcode.com/problems/time-based-key-value-store
|
|
1366,Rank Teams by Votes,53.8%,Medium,0.07223355735937158, https://leetcode.com/problems/rank-teams-by-votes
|
|
300,Longest Increasing Subsequence,42.6%,Medium,0.06265630749555627, https://leetcode.com/problems/longest-increasing-subsequence
|
|
359,Logger Rate Limiter,70.8%,Easy,0.0467617659080393, https://leetcode.com/problems/logger-rate-limiter
|
|
17,Letter Combinations of a Phone Number,46.8%,Medium,0.03893646375009422, https://leetcode.com/problems/letter-combinations-of-a-phone-number
|
|
150,Evaluate Reverse Polish Notation,36.3%,Medium,0.031526253646773944, https://leetcode.com/problems/evaluate-reverse-polish-notation
|
|
284,Peeking Iterator,45.7%,Medium,0.03110670713225487, https://leetcode.com/problems/peeking-iterator
|
|
31,Next Permutation,32.6%,Medium,0.023747034562878154, https://leetcode.com/problems/next-permutation
|
|
540,Single Element in a Sorted Array,57.9%,Medium,0.0192128868599912, https://leetcode.com/problems/single-element-in-a-sorted-array
|
|
98,Validate Binary Search Tree,27.8%,Medium,0.01825801101705589, https://leetcode.com/problems/validate-binary-search-tree
|
|
706,Design HashMap,61.3%,Easy,0.01752893260576219, https://leetcode.com/problems/design-hashmap
|
|
872,Leaf-Similar Trees,64.5%,Easy,0.01752125418714782, https://leetcode.com/problems/leaf-similar-trees
|
|
173,Binary Search Tree Iterator,56.6%,Medium,0.008489015324911316, https://leetcode.com/problems/binary-search-tree-iterator
|
|
236,Lowest Common Ancestor of a Binary Tree,45.7%,Medium,0.004714210262726446, https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree
|
|
22,Generate Parentheses,62.7%,Medium,0.0043611059090124735, https://leetcode.com/problems/generate-parentheses
|
|
46,Permutations,63.5%,Medium,0.004216302230139218, https://leetcode.com/problems/permutations
|
|
102,Binary Tree Level Order Traversal,54.6%,Medium,0.003639014205004082, https://leetcode.com/problems/binary-tree-level-order-traversal
|
|
3,Longest Substring Without Repeating Characters,30.4%,Medium,0.0015556336509412823, https://leetcode.com/problems/longest-substring-without-repeating-characters
|