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,25 +1,26 @@
256,Paint House,52.1%,Easy,0.03172360722570897, https://leetcode.com/problems/paint-house
143,Reorder List,37.1%,Medium,0.025870945598649286, https://leetcode.com/problems/reorder-list
33,Search in Rotated Sorted Array,34.5%,Medium,0.0200182839715896, https://leetcode.com/problems/search-in-rotated-sorted-array
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
21,Merge Two Sorted Lists,53.5%,Easy,0.014012111332134735, https://leetcode.com/problems/merge-two-sorted-lists
227,Basic Calculator II,36.9%,Medium,0.01239941490503826, https://leetcode.com/problems/basic-calculator-ii
543,Diameter of Binary Tree,48.4%,Easy,0.011898606798495848, https://leetcode.com/problems/diameter-of-binary-tree
121,Best Time to Buy and Sell Stock,50.5%,Easy,0.00846879565300311, https://leetcode.com/problems/best-time-to-buy-and-sell-stock
240,Search a 2D Matrix II,43.2%,Medium,0.0075829747244553335, https://leetcode.com/problems/search-a-2d-matrix-ii
136,Single Number,65.5%,Easy,0.006445166968713385, https://leetcode.com/problems/single-number
76,Minimum Window Substring,34.6%,Hard,0.006231520398723243, https://leetcode.com/problems/minimum-window-substring
287,Find the Duplicate Number,55.5%,Medium,0.005501320434837602, https://leetcode.com/problems/find-the-duplicate-number
206,Reverse Linked List,62.5%,Easy,0.005257021452801617, https://leetcode.com/problems/reverse-linked-list
15,3Sum,26.8%,Medium,0.004940992758742591, https://leetcode.com/problems/3sum
160,Intersection of Two Linked Lists,40.6%,Easy,0.004901369939720486, https://leetcode.com/problems/intersection-of-two-linked-lists
169,Majority Element,58.7%,Easy,0.004706444738837472, https://leetcode.com/problems/majority-element
215,Kth Largest Element in an Array,55.4%,Medium,0.003902443976931749, https://leetcode.com/problems/kth-largest-element-in-an-array
4,Median of Two Sorted Arrays,29.6%,Hard,0.003900160950094767, https://leetcode.com/problems/median-of-two-sorted-arrays
8,String to Integer (atoi),15.4%,Medium,0.0037925521897059712, https://leetcode.com/problems/string-to-integer-atoi
56,Merge Intervals,39.3%,Medium,0.0034728286335985107, https://leetcode.com/problems/merge-intervals
1,Two Sum,45.6%,Easy,0.003278422738041615, https://leetcode.com/problems/two-sum
20,Valid Parentheses,39.0%,Easy,0.0023005704055949323, https://leetcode.com/problems/valid-parentheses
5,Longest Palindromic Substring,29.5%,Medium,0.002279333142507479, https://leetcode.com/problems/longest-palindromic-substring
190,Reverse Bits,39.8%,Easy,0.0018316700789167337, https://leetcode.com/problems/reverse-bits
ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link
256,Paint House,52.1%,Easy,0.03172360722570897, https://leetcode.com/problems/paint-house
143,Reorder List,37.1%,Medium,0.025870945598649286, https://leetcode.com/problems/reorder-list
33,Search in Rotated Sorted Array,34.5%,Medium,0.0200182839715896, https://leetcode.com/problems/search-in-rotated-sorted-array
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
21,Merge Two Sorted Lists,53.5%,Easy,0.014012111332134735, https://leetcode.com/problems/merge-two-sorted-lists
227,Basic Calculator II,36.9%,Medium,0.01239941490503826, https://leetcode.com/problems/basic-calculator-ii
543,Diameter of Binary Tree,48.4%,Easy,0.011898606798495848, https://leetcode.com/problems/diameter-of-binary-tree
121,Best Time to Buy and Sell Stock,50.5%,Easy,0.00846879565300311, https://leetcode.com/problems/best-time-to-buy-and-sell-stock
240,Search a 2D Matrix II,43.2%,Medium,0.0075829747244553335, https://leetcode.com/problems/search-a-2d-matrix-ii
136,Single Number,65.5%,Easy,0.006445166968713385, https://leetcode.com/problems/single-number
76,Minimum Window Substring,34.6%,Hard,0.006231520398723243, https://leetcode.com/problems/minimum-window-substring
287,Find the Duplicate Number,55.5%,Medium,0.005501320434837602, https://leetcode.com/problems/find-the-duplicate-number
206,Reverse Linked List,62.5%,Easy,0.005257021452801617, https://leetcode.com/problems/reverse-linked-list
15,3Sum,26.8%,Medium,0.004940992758742591, https://leetcode.com/problems/3sum
160,Intersection of Two Linked Lists,40.6%,Easy,0.004901369939720486, https://leetcode.com/problems/intersection-of-two-linked-lists
169,Majority Element,58.7%,Easy,0.004706444738837472, https://leetcode.com/problems/majority-element
215,Kth Largest Element in an Array,55.4%,Medium,0.003902443976931749, https://leetcode.com/problems/kth-largest-element-in-an-array
4,Median of Two Sorted Arrays,29.6%,Hard,0.003900160950094767, https://leetcode.com/problems/median-of-two-sorted-arrays
8,String to Integer (atoi),15.4%,Medium,0.0037925521897059712, https://leetcode.com/problems/string-to-integer-atoi
56,Merge Intervals,39.3%,Medium,0.0034728286335985107, https://leetcode.com/problems/merge-intervals
1,Two Sum,45.6%,Easy,0.003278422738041615, https://leetcode.com/problems/two-sum
20,Valid Parentheses,39.0%,Easy,0.0023005704055949323, https://leetcode.com/problems/valid-parentheses
5,Longest Palindromic Substring,29.5%,Medium,0.002279333142507479, https://leetcode.com/problems/longest-palindromic-substring
190,Reverse Bits,39.8%,Easy,0.0018316700789167337, https://leetcode.com/problems/reverse-bits
1 256 ID Paint House Title 52.1% Acceptance Easy Difficulty 0.03172360722570897 Frequency https://leetcode.com/problems/paint-house Leetcode Question Link
2 143 256 Reorder List Paint House 37.1% 52.1% Medium Easy 0.025870945598649286 0.03172360722570897 https://leetcode.com/problems/reorder-list https://leetcode.com/problems/paint-house
3 33 143 Search in Rotated Sorted Array Reorder List 34.5% 37.1% Medium Medium 0.0200182839715896 0.025870945598649286 https://leetcode.com/problems/search-in-rotated-sorted-array https://leetcode.com/problems/reorder-list
4 1143 33 Longest Common Subsequence Search in Rotated Sorted Array 58.4% 34.5% Medium Medium 0.019772173115579716 0.0200182839715896 https://leetcode.com/problems/longest-common-subsequence https://leetcode.com/problems/search-in-rotated-sorted-array
5 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
6 21 394 Merge Two Sorted Lists Decode String 53.5% 50.0% Easy Medium 0.014012111332134735 0.0182820448374491 https://leetcode.com/problems/merge-two-sorted-lists https://leetcode.com/problems/decode-string
7 227 21 Basic Calculator II Merge Two Sorted Lists 36.9% 53.5% Medium Easy 0.01239941490503826 0.014012111332134735 https://leetcode.com/problems/basic-calculator-ii https://leetcode.com/problems/merge-two-sorted-lists
8 543 227 Diameter of Binary Tree Basic Calculator II 48.4% 36.9% Easy Medium 0.011898606798495848 0.01239941490503826 https://leetcode.com/problems/diameter-of-binary-tree https://leetcode.com/problems/basic-calculator-ii
9 121 543 Best Time to Buy and Sell Stock Diameter of Binary Tree 50.5% 48.4% Easy Easy 0.00846879565300311 0.011898606798495848 https://leetcode.com/problems/best-time-to-buy-and-sell-stock https://leetcode.com/problems/diameter-of-binary-tree
10 240 121 Search a 2D Matrix II Best Time to Buy and Sell Stock 43.2% 50.5% Medium Easy 0.0075829747244553335 0.00846879565300311 https://leetcode.com/problems/search-a-2d-matrix-ii https://leetcode.com/problems/best-time-to-buy-and-sell-stock
11 136 240 Single Number Search a 2D Matrix II 65.5% 43.2% Easy Medium 0.006445166968713385 0.0075829747244553335 https://leetcode.com/problems/single-number https://leetcode.com/problems/search-a-2d-matrix-ii
12 76 136 Minimum Window Substring Single Number 34.6% 65.5% Hard Easy 0.006231520398723243 0.006445166968713385 https://leetcode.com/problems/minimum-window-substring https://leetcode.com/problems/single-number
13 287 76 Find the Duplicate Number Minimum Window Substring 55.5% 34.6% Medium Hard 0.005501320434837602 0.006231520398723243 https://leetcode.com/problems/find-the-duplicate-number https://leetcode.com/problems/minimum-window-substring
14 206 287 Reverse Linked List Find the Duplicate Number 62.5% 55.5% Easy Medium 0.005257021452801617 0.005501320434837602 https://leetcode.com/problems/reverse-linked-list https://leetcode.com/problems/find-the-duplicate-number
15 15 206 3Sum Reverse Linked List 26.8% 62.5% Medium Easy 0.004940992758742591 0.005257021452801617 https://leetcode.com/problems/3sum https://leetcode.com/problems/reverse-linked-list
16 160 15 Intersection of Two Linked Lists 3Sum 40.6% 26.8% Easy Medium 0.004901369939720486 0.004940992758742591 https://leetcode.com/problems/intersection-of-two-linked-lists https://leetcode.com/problems/3sum
17 169 160 Majority Element Intersection of Two Linked Lists 58.7% 40.6% Easy Easy 0.004706444738837472 0.004901369939720486 https://leetcode.com/problems/majority-element https://leetcode.com/problems/intersection-of-two-linked-lists
18 215 169 Kth Largest Element in an Array Majority Element 55.4% 58.7% Medium Easy 0.003902443976931749 0.004706444738837472 https://leetcode.com/problems/kth-largest-element-in-an-array https://leetcode.com/problems/majority-element
19 4 215 Median of Two Sorted Arrays Kth Largest Element in an Array 29.6% 55.4% Hard Medium 0.003900160950094767 0.003902443976931749 https://leetcode.com/problems/median-of-two-sorted-arrays https://leetcode.com/problems/kth-largest-element-in-an-array
20 8 4 String to Integer (atoi) Median of Two Sorted Arrays 15.4% 29.6% Medium Hard 0.0037925521897059712 0.003900160950094767 https://leetcode.com/problems/string-to-integer-atoi https://leetcode.com/problems/median-of-two-sorted-arrays
21 56 8 Merge Intervals String to Integer (atoi) 39.3% 15.4% Medium Medium 0.0034728286335985107 0.0037925521897059712 https://leetcode.com/problems/merge-intervals https://leetcode.com/problems/string-to-integer-atoi
22 1 56 Two Sum Merge Intervals 45.6% 39.3% Easy Medium 0.003278422738041615 0.0034728286335985107 https://leetcode.com/problems/two-sum https://leetcode.com/problems/merge-intervals
23 20 1 Valid Parentheses Two Sum 39.0% 45.6% Easy Easy 0.0023005704055949323 0.003278422738041615 https://leetcode.com/problems/valid-parentheses https://leetcode.com/problems/two-sum
24 5 20 Longest Palindromic Substring Valid Parentheses 29.5% 39.0% Medium Easy 0.002279333142507479 0.0023005704055949323 https://leetcode.com/problems/longest-palindromic-substring https://leetcode.com/problems/valid-parentheses
25 190 5 Reverse Bits Longest Palindromic Substring 39.8% 29.5% Easy Medium 0.0018316700789167337 0.002279333142507479 https://leetcode.com/problems/reverse-bits https://leetcode.com/problems/longest-palindromic-substring
26 190 Reverse Bits 39.8% Easy 0.0018316700789167337 https://leetcode.com/problems/reverse-bits