Chore: Add headers to all the files (#54)

## 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)

```
This commit is contained in:
Krishna Kumar Dey
2023-04-01 11:07:49 +05:30
committed by GitHub
parent 0aeadbd612
commit fb5f78b55e
534 changed files with 20291 additions and 19757 deletions

View File

@@ -1,27 +1,28 @@
1,Two Sum,45.6%,Easy,0.6244209657434179, https://leetcode.com/problems/two-sum
169,Majority Element,58.7%,Easy,0.5183921604769917, https://leetcode.com/problems/majority-element
5,Longest Palindromic Substring,29.5%,Medium,0.5065034436015775, https://leetcode.com/problems/longest-palindromic-substring
206,Reverse Linked List,62.5%,Easy,0.4004746383351513, https://leetcode.com/problems/reverse-linked-list
8,String to Integer (atoi),15.4%,Medium,0.34989797105896764, https://leetcode.com/problems/string-to-integer-atoi
4,Median of Two Sorted Arrays,29.6%,Hard,0.2749994072467641, https://leetcode.com/problems/median-of-two-sorted-arrays
21,Merge Two Sorted Lists,53.5%,Easy,0.24152080844569923, https://leetcode.com/problems/merge-two-sorted-lists
215,Kth Largest Element in an Array,55.4%,Medium,0.22333903562721621, https://leetcode.com/problems/kth-largest-element-in-an-array
160,Intersection of Two Linked Lists,40.6%,Easy,0.13857026686146906, https://leetcode.com/problems/intersection-of-two-linked-lists
20,Valid Parentheses,39.0%,Easy,0.10693122823835342, https://leetcode.com/problems/valid-parentheses
136,Single Number,65.5%,Easy,0.08335861851743445, https://leetcode.com/problems/single-number
33,Search in Rotated Sorted Array,34.5%,Medium,0.07777550022464022, https://leetcode.com/problems/search-in-rotated-sorted-array
240,Search a 2D Matrix II,43.2%,Medium,0.04647676584572884, https://leetcode.com/problems/search-a-2d-matrix-ii
143,Reorder List,37.1%,Medium,0.04554002588608351, https://leetcode.com/problems/reorder-list
121,Best Time to Buy and Sell Stock,50.5%,Easy,0.04215422741819192, https://leetcode.com/problems/best-time-to-buy-and-sell-stock
256,Paint House,52.1%,Easy,0.03937516523483013, https://leetcode.com/problems/paint-house
15,3Sum,26.8%,Medium,0.0346167609048592, https://leetcode.com/problems/3sum
287,Find the Duplicate Number,55.5%,Medium,0.033896954598043594, https://leetcode.com/problems/find-the-duplicate-number
543,Diameter of Binary Tree,48.4%,Easy,0.032708305572393875, https://leetcode.com/problems/diameter-of-binary-tree
1143,Longest Common Subsequence,58.4%,Medium,0.019772173115579716, https://leetcode.com/problems/longest-common-subsequence
394,Decode String,50.0%,Medium,0.0182820448374491, https://leetcode.com/problems/decode-string
76,Minimum Window Substring,34.6%,Hard,0.013966707481708198, https://leetcode.com/problems/minimum-window-substring
227,Basic Calculator II,36.9%,Medium,0.01239941490503826, https://leetcode.com/problems/basic-calculator-ii
56,Merge Intervals,39.3%,Medium,0.0034728286335985107, https://leetcode.com/problems/merge-intervals
190,Reverse Bits,39.8%,Easy,0.0018316700789167337, https://leetcode.com/problems/reverse-bits
546,Remove Boxes,42.7%,Hard,0, https://leetcode.com/problems/remove-boxes
625,Minimum Factorization,32.8%,Medium,0, https://leetcode.com/problems/minimum-factorization
ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link
1,Two Sum,45.6%,Easy,0.6244209657434179, https://leetcode.com/problems/two-sum
169,Majority Element,58.7%,Easy,0.5183921604769917, https://leetcode.com/problems/majority-element
5,Longest Palindromic Substring,29.5%,Medium,0.5065034436015775, https://leetcode.com/problems/longest-palindromic-substring
206,Reverse Linked List,62.5%,Easy,0.4004746383351513, https://leetcode.com/problems/reverse-linked-list
8,String to Integer (atoi),15.4%,Medium,0.34989797105896764, https://leetcode.com/problems/string-to-integer-atoi
4,Median of Two Sorted Arrays,29.6%,Hard,0.2749994072467641, https://leetcode.com/problems/median-of-two-sorted-arrays
21,Merge Two Sorted Lists,53.5%,Easy,0.24152080844569923, https://leetcode.com/problems/merge-two-sorted-lists
215,Kth Largest Element in an Array,55.4%,Medium,0.22333903562721621, https://leetcode.com/problems/kth-largest-element-in-an-array
160,Intersection of Two Linked Lists,40.6%,Easy,0.13857026686146906, https://leetcode.com/problems/intersection-of-two-linked-lists
20,Valid Parentheses,39.0%,Easy,0.10693122823835342, https://leetcode.com/problems/valid-parentheses
136,Single Number,65.5%,Easy,0.08335861851743445, https://leetcode.com/problems/single-number
33,Search in Rotated Sorted Array,34.5%,Medium,0.07777550022464022, https://leetcode.com/problems/search-in-rotated-sorted-array
240,Search a 2D Matrix II,43.2%,Medium,0.04647676584572884, https://leetcode.com/problems/search-a-2d-matrix-ii
143,Reorder List,37.1%,Medium,0.04554002588608351, https://leetcode.com/problems/reorder-list
121,Best Time to Buy and Sell Stock,50.5%,Easy,0.04215422741819192, https://leetcode.com/problems/best-time-to-buy-and-sell-stock
256,Paint House,52.1%,Easy,0.03937516523483013, https://leetcode.com/problems/paint-house
15,3Sum,26.8%,Medium,0.0346167609048592, https://leetcode.com/problems/3sum
287,Find the Duplicate Number,55.5%,Medium,0.033896954598043594, https://leetcode.com/problems/find-the-duplicate-number
543,Diameter of Binary Tree,48.4%,Easy,0.032708305572393875, https://leetcode.com/problems/diameter-of-binary-tree
1143,Longest Common Subsequence,58.4%,Medium,0.019772173115579716, https://leetcode.com/problems/longest-common-subsequence
394,Decode String,50.0%,Medium,0.0182820448374491, https://leetcode.com/problems/decode-string
76,Minimum Window Substring,34.6%,Hard,0.013966707481708198, https://leetcode.com/problems/minimum-window-substring
227,Basic Calculator II,36.9%,Medium,0.01239941490503826, https://leetcode.com/problems/basic-calculator-ii
56,Merge Intervals,39.3%,Medium,0.0034728286335985107, https://leetcode.com/problems/merge-intervals
190,Reverse Bits,39.8%,Easy,0.0018316700789167337, https://leetcode.com/problems/reverse-bits
546,Remove Boxes,42.7%,Hard,0, https://leetcode.com/problems/remove-boxes
625,Minimum Factorization,32.8%,Medium,0, https://leetcode.com/problems/minimum-factorization
1 1 ID Two Sum Title 45.6% Acceptance Easy Difficulty 0.6244209657434179 Frequency https://leetcode.com/problems/two-sum Leetcode Question Link
2 169 1 Majority Element Two Sum 58.7% 45.6% Easy Easy 0.5183921604769917 0.6244209657434179 https://leetcode.com/problems/majority-element https://leetcode.com/problems/two-sum
3 5 169 Longest Palindromic Substring Majority Element 29.5% 58.7% Medium Easy 0.5065034436015775 0.5183921604769917 https://leetcode.com/problems/longest-palindromic-substring https://leetcode.com/problems/majority-element
4 206 5 Reverse Linked List Longest Palindromic Substring 62.5% 29.5% Easy Medium 0.4004746383351513 0.5065034436015775 https://leetcode.com/problems/reverse-linked-list https://leetcode.com/problems/longest-palindromic-substring
5 8 206 String to Integer (atoi) Reverse Linked List 15.4% 62.5% Medium Easy 0.34989797105896764 0.4004746383351513 https://leetcode.com/problems/string-to-integer-atoi https://leetcode.com/problems/reverse-linked-list
6 4 8 Median of Two Sorted Arrays String to Integer (atoi) 29.6% 15.4% Hard Medium 0.2749994072467641 0.34989797105896764 https://leetcode.com/problems/median-of-two-sorted-arrays https://leetcode.com/problems/string-to-integer-atoi
7 21 4 Merge Two Sorted Lists Median of Two Sorted Arrays 53.5% 29.6% Easy Hard 0.24152080844569923 0.2749994072467641 https://leetcode.com/problems/merge-two-sorted-lists https://leetcode.com/problems/median-of-two-sorted-arrays
8 215 21 Kth Largest Element in an Array Merge Two Sorted Lists 55.4% 53.5% Medium Easy 0.22333903562721621 0.24152080844569923 https://leetcode.com/problems/kth-largest-element-in-an-array https://leetcode.com/problems/merge-two-sorted-lists
9 160 215 Intersection of Two Linked Lists Kth Largest Element in an Array 40.6% 55.4% Easy Medium 0.13857026686146906 0.22333903562721621 https://leetcode.com/problems/intersection-of-two-linked-lists https://leetcode.com/problems/kth-largest-element-in-an-array
10 20 160 Valid Parentheses Intersection of Two Linked Lists 39.0% 40.6% Easy Easy 0.10693122823835342 0.13857026686146906 https://leetcode.com/problems/valid-parentheses https://leetcode.com/problems/intersection-of-two-linked-lists
11 136 20 Single Number Valid Parentheses 65.5% 39.0% Easy Easy 0.08335861851743445 0.10693122823835342 https://leetcode.com/problems/single-number https://leetcode.com/problems/valid-parentheses
12 33 136 Search in Rotated Sorted Array Single Number 34.5% 65.5% Medium Easy 0.07777550022464022 0.08335861851743445 https://leetcode.com/problems/search-in-rotated-sorted-array https://leetcode.com/problems/single-number
13 240 33 Search a 2D Matrix II Search in Rotated Sorted Array 43.2% 34.5% Medium Medium 0.04647676584572884 0.07777550022464022 https://leetcode.com/problems/search-a-2d-matrix-ii https://leetcode.com/problems/search-in-rotated-sorted-array
14 143 240 Reorder List Search a 2D Matrix II 37.1% 43.2% Medium Medium 0.04554002588608351 0.04647676584572884 https://leetcode.com/problems/reorder-list https://leetcode.com/problems/search-a-2d-matrix-ii
15 121 143 Best Time to Buy and Sell Stock Reorder List 50.5% 37.1% Easy Medium 0.04215422741819192 0.04554002588608351 https://leetcode.com/problems/best-time-to-buy-and-sell-stock https://leetcode.com/problems/reorder-list
16 256 121 Paint House Best Time to Buy and Sell Stock 52.1% 50.5% Easy Easy 0.03937516523483013 0.04215422741819192 https://leetcode.com/problems/paint-house https://leetcode.com/problems/best-time-to-buy-and-sell-stock
17 15 256 3Sum Paint House 26.8% 52.1% Medium Easy 0.0346167609048592 0.03937516523483013 https://leetcode.com/problems/3sum https://leetcode.com/problems/paint-house
18 287 15 Find the Duplicate Number 3Sum 55.5% 26.8% Medium Medium 0.033896954598043594 0.0346167609048592 https://leetcode.com/problems/find-the-duplicate-number https://leetcode.com/problems/3sum
19 543 287 Diameter of Binary Tree Find the Duplicate Number 48.4% 55.5% Easy Medium 0.032708305572393875 0.033896954598043594 https://leetcode.com/problems/diameter-of-binary-tree https://leetcode.com/problems/find-the-duplicate-number
20 1143 543 Longest Common Subsequence Diameter of Binary Tree 58.4% 48.4% Medium Easy 0.019772173115579716 0.032708305572393875 https://leetcode.com/problems/longest-common-subsequence https://leetcode.com/problems/diameter-of-binary-tree
21 394 1143 Decode String Longest Common Subsequence 50.0% 58.4% Medium Medium 0.0182820448374491 0.019772173115579716 https://leetcode.com/problems/decode-string https://leetcode.com/problems/longest-common-subsequence
22 76 394 Minimum Window Substring Decode String 34.6% 50.0% Hard Medium 0.013966707481708198 0.0182820448374491 https://leetcode.com/problems/minimum-window-substring https://leetcode.com/problems/decode-string
23 227 76 Basic Calculator II Minimum Window Substring 36.9% 34.6% Medium Hard 0.01239941490503826 0.013966707481708198 https://leetcode.com/problems/basic-calculator-ii https://leetcode.com/problems/minimum-window-substring
24 56 227 Merge Intervals Basic Calculator II 39.3% 36.9% Medium Medium 0.0034728286335985107 0.01239941490503826 https://leetcode.com/problems/merge-intervals https://leetcode.com/problems/basic-calculator-ii
25 190 56 Reverse Bits Merge Intervals 39.8% 39.3% Easy Medium 0.0018316700789167337 0.0034728286335985107 https://leetcode.com/problems/reverse-bits https://leetcode.com/problems/merge-intervals
26 546 190 Remove Boxes Reverse Bits 42.7% 39.8% Hard Easy 0 0.0018316700789167337 https://leetcode.com/problems/remove-boxes https://leetcode.com/problems/reverse-bits
27 625 546 Minimum Factorization Remove Boxes 32.8% 42.7% Medium Hard 0 0 https://leetcode.com/problems/minimum-factorization https://leetcode.com/problems/remove-boxes
28 625 Minimum Factorization 32.8% Medium 0 https://leetcode.com/problems/minimum-factorization