mirror of
https://github.com/krishnadey30/LeetCode-Questions-CompanyWise.git
synced 2025-12-28 05:34:42 +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)
```
2.9 KiB
2.9 KiB
| 1 | ID | Title | Acceptance | Difficulty | Frequency | Leetcode Question Link |
|---|---|---|---|---|---|---|
| 2 | 1473 | Paint House III | 48.1% | Hard | 0.4279239789584774 | https://leetcode.com/problems/paint-house-iii |
| 3 | 1041 | Robot Bounded In Circle | 49.6% | Medium | 0.26986631760028884 | https://leetcode.com/problems/robot-bounded-in-circle |
| 4 | 1497 | Check If Array Pairs Are Divisible by k | 41.1% | Medium | 0.2357666456855048 | https://leetcode.com/problems/check-if-array-pairs-are-divisible-by-k |
| 5 | 1297 | Maximum Number of Occurrences of a Substring | 47.3% | Medium | 0.07770898432731625 | https://leetcode.com/problems/maximum-number-of-occurrences-of-a-substring |
| 6 | 56 | Merge Intervals | 39.3% | Medium | 0.04173304225331761 | https://leetcode.com/problems/merge-intervals |
| 7 | 243 | Shortest Word Distance | 61.0% | Easy | 0.040780370344928096 | https://leetcode.com/problems/shortest-word-distance |
| 8 | 324 | Wiggle Sort II | 29.9% | Medium | 0.02898753687325229 | https://leetcode.com/problems/wiggle-sort-ii |
| 9 | 68 | Text Justification | 27.7% | Hard | 0.0276451606661453 | https://leetcode.com/problems/text-justification |
| 10 | 12 | Integer to Roman | 55.1% | Medium | 0.019096697456456382 | https://leetcode.com/problems/integer-to-roman |
| 11 | 146 | LRU Cache | 33.2% | Medium | 0.01827577993873683 | https://leetcode.com/problems/lru-cache |
| 12 | 73 | Set Matrix Zeroes | 43.1% | Medium | 0.015715357479628243 | https://leetcode.com/problems/set-matrix-zeroes |
| 13 | 977 | Squares of a Sorted Array | 72.1% | Easy | 0.015474196582597383 | https://leetcode.com/problems/squares-of-a-sorted-array |
| 14 | 20 | Valid Parentheses | 39.0% | Easy | 0.014292491180025941 | https://leetcode.com/problems/valid-parentheses |
| 15 | 1047 | Remove All Adjacent Duplicates In String | 68.6% | Easy | 0.013059277989179281 | https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string |
| 16 | 227 | Basic Calculator II | 36.9% | Medium | 0.01239941490503826 | https://leetcode.com/problems/basic-calculator-ii |
| 17 | 242 | Valid Anagram | 56.9% | Easy | 0.009322628116274939 | https://leetcode.com/problems/valid-anagram |
| 18 | 128 | Longest Consecutive Sequence | 45.1% | Hard | 0.009051883485315484 | https://leetcode.com/problems/longest-consecutive-sequence |
| 19 | 876 | Middle of the Linked List | 68.4% | Easy | 0.007624893975696915 | https://leetcode.com/problems/middle-of-the-linked-list |
| 20 | 2 | Add Two Numbers | 33.9% | Medium | 0.006737434951993369 | https://leetcode.com/problems/add-two-numbers |
| 21 | 973 | K Closest Points to Origin | 63.8% | Medium | 0.005773688094426333 | https://leetcode.com/problems/k-closest-points-to-origin |
| 22 | 75 | Sort Colors | 47.3% | Medium | 0.004992521603120986 | https://leetcode.com/problems/sort-colors |
| 23 | 53 | Maximum Subarray | 46.5% | Easy | 0.004869349014182134 | https://leetcode.com/problems/maximum-subarray |
| 24 | 189 | Rotate Array | 34.7% | Easy | 0.004029826126500844 | https://leetcode.com/problems/rotate-array |
| 25 | 1 | Two Sum | 45.6% | Easy | 0.003278422738041615 | https://leetcode.com/problems/two-sum |
| 26 | 5 | Longest Palindromic Substring | 29.5% | Medium | 0.002279333142507479 | https://leetcode.com/problems/longest-palindromic-substring |
| 27 | 15 | 3Sum | 26.8% | Medium | 0.0021990113314367685 | https://leetcode.com/problems/3sum |