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)
```
21 lines
2.2 KiB
CSV
21 lines
2.2 KiB
CSV
ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link
|
|
811,Subdomain Visit Count,69.9%,Easy,1.219366809852767, https://leetcode.com/problems/subdomain-visit-count
|
|
829,Consecutive Numbers Sum,37.5%,Hard,0.9369106040185756, https://leetcode.com/problems/consecutive-numbers-sum
|
|
770,Basic Calculator IV,48.1%,Hard,0.6957297563903937, https://leetcode.com/problems/basic-calculator-iv
|
|
1163,Last Substring in Lexicographical Order,33.9%,Hard,0.4636668007546091, https://leetcode.com/problems/last-substring-in-lexicographical-order
|
|
224,Basic Calculator,36.8%,Hard,0.44951029049735747, https://leetcode.com/problems/basic-calculator
|
|
1297,Maximum Number of Occurrences of a Substring,47.3%,Medium,0.1670540846631662, https://leetcode.com/problems/maximum-number-of-occurrences-of-a-substring
|
|
1328,Break a Palindrome,43.3%,Medium,0.12838116664820678, https://leetcode.com/problems/break-a-palindrome
|
|
1248,Count Number of Nice Subarrays,56.4%,Medium,0.1005310110120055, https://leetcode.com/problems/count-number-of-nice-subarrays
|
|
146,LRU Cache,33.2%,Medium,0.054946555458745445, https://leetcode.com/problems/lru-cache
|
|
239,Sliding Window Maximum,43.0%,Hard,0.0483746857022364, https://leetcode.com/problems/sliding-window-maximum
|
|
1290,Convert Binary Number in a Linked List to Integer,80.4%,Easy,0.04161848998251485, https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer
|
|
37,Sudoku Solver,43.6%,Hard,0.01821543989134118, https://leetcode.com/problems/sudoku-solver
|
|
17,Letter Combinations of a Phone Number,46.8%,Medium,0.017492519932499718, https://leetcode.com/problems/letter-combinations-of-a-phone-number
|
|
36,Valid Sudoku,48.7%,Medium,0.01625758350956095, https://leetcode.com/problems/valid-sudoku
|
|
647,Palindromic Substrings,60.6%,Medium,0.010400509768078022, https://leetcode.com/problems/palindromic-substrings
|
|
212,Word Search II,34.9%,Hard,0.009845021678804893, https://leetcode.com/problems/word-search-ii
|
|
5,Longest Palindromic Substring,29.5%,Medium,0.009086325220960808, https://leetcode.com/problems/longest-palindromic-substring
|
|
200,Number of Islands,46.8%,Medium,0.0028897578265903614, https://leetcode.com/problems/number-of-islands
|
|
1,Two Sum,45.6%,Easy,0.0008206138651873125, https://leetcode.com/problems/two-sum
|