mirror of
https://github.com/krishnadey30/LeetCode-Questions-CompanyWise.git
synced 2025-12-28 13:41: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)
```
5.0 KiB
5.0 KiB
| 1 | ID | Title | Acceptance | Difficulty | Frequency | Leetcode Question Link |
|---|---|---|---|---|---|---|
| 2 | 1168 | Optimize Water Distribution in a Village | 60.9% | Hard | 0.15241098168923292 | https://leetcode.com/problems/optimize-water-distribution-in-a-village |
| 3 | 1 | Two Sum | 45.6% | Easy | 0.09086581558650506 | https://leetcode.com/problems/two-sum |
| 4 | 384 | Shuffle an Array | 52.8% | Medium | 0.08855339734144506 | https://leetcode.com/problems/shuffle-an-array |
| 5 | 146 | LRU Cache | 33.2% | Medium | 0.027008231238717192 | https://leetcode.com/problems/lru-cache |
| 6 | 11 | Container With Most Water | 50.8% | Medium | 0.026255883963365544 | https://leetcode.com/problems/container-with-most-water |
| 7 | 605 | Can Place Flowers | 31.6% | Easy | 0.023502844454782748 | https://leetcode.com/problems/can-place-flowers |
| 8 | 2 | Add Two Numbers | 33.9% | Medium | 0.019661976799320476 | https://leetcode.com/problems/add-two-numbers |
| 9 | 60 | Permutation Sequence | 38.4% | Hard | 0.019268418865877057 | https://leetcode.com/problems/permutation-sequence |
| 10 | 75 | Sort Colors | 47.3% | Medium | 0.01900520441164089 | https://leetcode.com/problems/sort-colors |
| 11 | 669 | Trim a Binary Search Tree | 63.0% | Easy | 0.01838287060053348 | https://leetcode.com/problems/trim-a-binary-search-tree |
| 12 | 95 | Unique Binary Search Trees II | 40.6% | Medium | 0.016142400559542854 | https://leetcode.com/problems/unique-binary-search-trees-ii |
| 13 | 178 | Rank Scores | 45.8% | Medium | 0.01606460250380669 | https://leetcode.com/problems/rank-scores |
| 14 | 334 | Increasing Triplet Subsequence | 40.0% | Medium | 0.015444322427473612 | https://leetcode.com/problems/increasing-triplet-subsequence |
| 15 | 215 | Kth Largest Element in an Array | 55.4% | Medium | 0.014861874883289309 | https://leetcode.com/problems/kth-largest-element-in-an-array |
| 16 | 21 | Merge Two Sorted Lists | 53.5% | Easy | 0.013412218221408144 | https://leetcode.com/problems/merge-two-sorted-lists |
| 17 | 131 | Palindrome Partitioning | 47.5% | Medium | 0.013236460625830901 | https://leetcode.com/problems/palindrome-partitioning |
| 18 | 138 | Copy List with Random Pointer | 36.4% | Medium | 0.013217992416083225 | https://leetcode.com/problems/copy-list-with-random-pointer |
| 19 | 13 | Roman to Integer | 55.7% | Easy | 0.01303586978808304 | https://leetcode.com/problems/roman-to-integer |
| 20 | 77 | Combinations | 54.7% | Medium | 0.011908446770635425 | https://leetcode.com/problems/combinations |
| 21 | 518 | Coin Change 2 | 50.2% | Medium | 0.011844971180548993 | https://leetcode.com/problems/coin-change-2 |
| 22 | 445 | Add Two Numbers II | 54.5% | Medium | 0.011785640248472312 | https://leetcode.com/problems/add-two-numbers-ii |
| 23 | 200 | Number of Islands | 46.8% | Medium | 0.011015601921505717 | https://leetcode.com/problems/number-of-islands |
| 24 | 23 | Merge k Sorted Lists | 40.2% | Hard | 0.008699909875545938 | https://leetcode.com/problems/merge-k-sorted-lists |
| 25 | 416 | Partition Equal Subset Sum | 43.7% | Medium | 0.008297081408754006 | https://leetcode.com/problems/partition-equal-subset-sum |
| 26 | 1108 | Defanging an IP Address | 87.5% | Easy | 0.0070151111959223245 | https://leetcode.com/problems/defanging-an-ip-address |
| 27 | 33 | Search in Rotated Sorted Array | 34.5% | Medium | 0.006961661779487692 | https://leetcode.com/problems/search-in-rotated-sorted-array |
| 28 | 114 | Flatten Binary Tree to Linked List | 49.3% | Medium | 0.00661815784247808 | https://leetcode.com/problems/flatten-binary-tree-to-linked-list |
| 29 | 448 | Find All Numbers Disappeared in an Array | 55.9% | Easy | 0.006552029991300186 | https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array |
| 30 | 206 | Reverse Linked List | 62.5% | Easy | 0.005014496801245667 | https://leetcode.com/problems/reverse-linked-list |
| 31 | 207 | Course Schedule | 43.1% | Medium | 0.004736539346673217 | https://leetcode.com/problems/course-schedule |
| 32 | 160 | Intersection of Two Linked Lists | 40.6% | Easy | 0.00469264117819222 | https://leetcode.com/problems/intersection-of-two-linked-lists |
| 33 | 53 | Maximum Subarray | 46.5% | Easy | 0.004661771624924951 | https://leetcode.com/problems/maximum-subarray |
| 34 | 169 | Majority Element | 58.7% | Easy | 0.004513152193965855 | https://leetcode.com/problems/majority-element |
| 35 | 22 | Generate Parentheses | 62.7% | Medium | 0.004152398782798953 | https://leetcode.com/problems/generate-parentheses |
| 36 | 42 | Trapping Rain Water | 48.9% | Hard | 0.00411947029523883 | https://leetcode.com/problems/trapping-rain-water |
| 37 | 560 | Subarray Sum Equals K | 43.9% | Medium | 0.00407664649376343 | https://leetcode.com/problems/subarray-sum-equals-k |
| 38 | 7 | Reverse Integer | 25.8% | Easy | 0.004006593972128933 | https://leetcode.com/problems/reverse-integer |
| 39 | 46 | Permutations | 63.5% | Medium | 0.003984069014874407 | https://leetcode.com/problems/permutations |
| 40 | 4 | Median of Two Sorted Arrays | 29.6% | Hard | 0.00371713094107092 | https://leetcode.com/problems/median-of-two-sorted-arrays |
| 41 | 49 | Group Anagrams | 56.9% | Medium | 0.0036347154963361594 | https://leetcode.com/problems/group-anagrams |
| 42 | 283 | Move Zeroes | 57.8% | Easy | 0.002758622439079723 | https://leetcode.com/problems/move-zeroes |
| 43 | 20 | Valid Parentheses | 39.0% | Easy | 0.002197682330605871 | https://leetcode.com/problems/valid-parentheses |
| 44 | 5 | Longest Palindromic Substring | 29.5% | Medium | 0.0021771085723255794 | https://leetcode.com/problems/longest-palindromic-substring |
| 45 | 260 | Single Number III | 64.3% | Medium | 0.002022143148991901 | https://leetcode.com/problems/single-number-iii |
| 46 | 3 | Longest Substring Without Repeating Characters | 30.4% | Medium | 0.0014852223137141987 | https://leetcode.com/problems/longest-substring-without-repeating-characters |