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,22 +1,23 @@
202,Happy Number,50.4%,Easy,3.472501931831341, https://leetcode.com/problems/happy-number
20,Valid Parentheses,39.0%,Easy,2.091183527592892, https://leetcode.com/problems/valid-parentheses
322,Coin Change,35.5%,Medium,0.7098651233544434, https://leetcode.com/problems/coin-change
121,Best Time to Buy and Sell Stock,50.5%,Easy,0.24778819384825912, https://leetcode.com/problems/best-time-to-buy-and-sell-stock
1328,Break a Palindrome,43.3%,Medium,0.21795507637539235, https://leetcode.com/problems/break-a-palindrome
31,Next Permutation,32.6%,Medium,0.11480808652664298, https://leetcode.com/problems/next-permutation
273,Integer to English Words,27.1%,Hard,0.10380963271229693, https://leetcode.com/problems/integer-to-english-words
9,Palindrome Number,48.4%,Easy,0.08804403243108966, https://leetcode.com/problems/palindrome-number
1,Two Sum,45.6%,Easy,0.07889903801250679, https://leetcode.com/problems/two-sum
7,Reverse Integer,25.8%,Easy,0.054824382173728654, https://leetcode.com/problems/reverse-integer
17,Letter Combinations of a Phone Number,46.8%,Medium,0.052632421620123555, https://leetcode.com/problems/letter-combinations-of-a-phone-number
200,Number of Islands,46.8%,Medium,0.04526299408355752, https://leetcode.com/problems/number-of-islands
53,Maximum Subarray,46.5%,Easy,0.04299340685592046, https://leetcode.com/problems/maximum-subarray
5,Longest Palindromic Substring,29.5%,Medium,0.035860192879893796, https://leetcode.com/problems/longest-palindromic-substring
4,Median of Two Sorted Arrays,29.6%,Hard,0.034565653112280895, https://leetcode.com/problems/median-of-two-sorted-arrays
33,Search in Rotated Sorted Array,34.5%,Medium,0.0287009496170278, https://leetcode.com/problems/search-in-rotated-sorted-array
146,LRU Cache,33.2%,Medium,0.028411001832779885, https://leetcode.com/problems/lru-cache
349,Intersection of Two Arrays,62.5%,Easy,0.016239981598488416, https://leetcode.com/problems/intersection-of-two-arrays
79,Word Search,35.6%,Medium,0.014883688014740005, https://leetcode.com/problems/word-search
215,Kth Largest Element in an Array,55.4%,Medium,0.008759180089881562, https://leetcode.com/problems/kth-largest-element-in-an-array
39,Combination Sum,56.1%,Medium,0.005715934396440999, https://leetcode.com/problems/combination-sum
387,First Unique Character in a String,53.4%,Easy,0.00418541994270691, https://leetcode.com/problems/first-unique-character-in-a-string
ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link
202,Happy Number,50.4%,Easy,3.472501931831341, https://leetcode.com/problems/happy-number
20,Valid Parentheses,39.0%,Easy,2.091183527592892, https://leetcode.com/problems/valid-parentheses
322,Coin Change,35.5%,Medium,0.7098651233544434, https://leetcode.com/problems/coin-change
121,Best Time to Buy and Sell Stock,50.5%,Easy,0.24778819384825912, https://leetcode.com/problems/best-time-to-buy-and-sell-stock
1328,Break a Palindrome,43.3%,Medium,0.21795507637539235, https://leetcode.com/problems/break-a-palindrome
31,Next Permutation,32.6%,Medium,0.11480808652664298, https://leetcode.com/problems/next-permutation
273,Integer to English Words,27.1%,Hard,0.10380963271229693, https://leetcode.com/problems/integer-to-english-words
9,Palindrome Number,48.4%,Easy,0.08804403243108966, https://leetcode.com/problems/palindrome-number
1,Two Sum,45.6%,Easy,0.07889903801250679, https://leetcode.com/problems/two-sum
7,Reverse Integer,25.8%,Easy,0.054824382173728654, https://leetcode.com/problems/reverse-integer
17,Letter Combinations of a Phone Number,46.8%,Medium,0.052632421620123555, https://leetcode.com/problems/letter-combinations-of-a-phone-number
200,Number of Islands,46.8%,Medium,0.04526299408355752, https://leetcode.com/problems/number-of-islands
53,Maximum Subarray,46.5%,Easy,0.04299340685592046, https://leetcode.com/problems/maximum-subarray
5,Longest Palindromic Substring,29.5%,Medium,0.035860192879893796, https://leetcode.com/problems/longest-palindromic-substring
4,Median of Two Sorted Arrays,29.6%,Hard,0.034565653112280895, https://leetcode.com/problems/median-of-two-sorted-arrays
33,Search in Rotated Sorted Array,34.5%,Medium,0.0287009496170278, https://leetcode.com/problems/search-in-rotated-sorted-array
146,LRU Cache,33.2%,Medium,0.028411001832779885, https://leetcode.com/problems/lru-cache
349,Intersection of Two Arrays,62.5%,Easy,0.016239981598488416, https://leetcode.com/problems/intersection-of-two-arrays
79,Word Search,35.6%,Medium,0.014883688014740005, https://leetcode.com/problems/word-search
215,Kth Largest Element in an Array,55.4%,Medium,0.008759180089881562, https://leetcode.com/problems/kth-largest-element-in-an-array
39,Combination Sum,56.1%,Medium,0.005715934396440999, https://leetcode.com/problems/combination-sum
387,First Unique Character in a String,53.4%,Easy,0.00418541994270691, https://leetcode.com/problems/first-unique-character-in-a-string
1 202 ID Happy Number Title 50.4% Acceptance Easy Difficulty 3.472501931831341 Frequency https://leetcode.com/problems/happy-number Leetcode Question Link
2 20 202 Valid Parentheses Happy Number 39.0% 50.4% Easy Easy 2.091183527592892 3.472501931831341 https://leetcode.com/problems/valid-parentheses https://leetcode.com/problems/happy-number
3 322 20 Coin Change Valid Parentheses 35.5% 39.0% Medium Easy 0.7098651233544434 2.091183527592892 https://leetcode.com/problems/coin-change https://leetcode.com/problems/valid-parentheses
4 121 322 Best Time to Buy and Sell Stock Coin Change 50.5% 35.5% Easy Medium 0.24778819384825912 0.7098651233544434 https://leetcode.com/problems/best-time-to-buy-and-sell-stock https://leetcode.com/problems/coin-change
5 1328 121 Break a Palindrome Best Time to Buy and Sell Stock 43.3% 50.5% Medium Easy 0.21795507637539235 0.24778819384825912 https://leetcode.com/problems/break-a-palindrome https://leetcode.com/problems/best-time-to-buy-and-sell-stock
6 31 1328 Next Permutation Break a Palindrome 32.6% 43.3% Medium Medium 0.11480808652664298 0.21795507637539235 https://leetcode.com/problems/next-permutation https://leetcode.com/problems/break-a-palindrome
7 273 31 Integer to English Words Next Permutation 27.1% 32.6% Hard Medium 0.10380963271229693 0.11480808652664298 https://leetcode.com/problems/integer-to-english-words https://leetcode.com/problems/next-permutation
8 9 273 Palindrome Number Integer to English Words 48.4% 27.1% Easy Hard 0.08804403243108966 0.10380963271229693 https://leetcode.com/problems/palindrome-number https://leetcode.com/problems/integer-to-english-words
9 1 9 Two Sum Palindrome Number 45.6% 48.4% Easy Easy 0.07889903801250679 0.08804403243108966 https://leetcode.com/problems/two-sum https://leetcode.com/problems/palindrome-number
10 7 1 Reverse Integer Two Sum 25.8% 45.6% Easy Easy 0.054824382173728654 0.07889903801250679 https://leetcode.com/problems/reverse-integer https://leetcode.com/problems/two-sum
11 17 7 Letter Combinations of a Phone Number Reverse Integer 46.8% 25.8% Medium Easy 0.052632421620123555 0.054824382173728654 https://leetcode.com/problems/letter-combinations-of-a-phone-number https://leetcode.com/problems/reverse-integer
12 200 17 Number of Islands Letter Combinations of a Phone Number 46.8% 46.8% Medium Medium 0.04526299408355752 0.052632421620123555 https://leetcode.com/problems/number-of-islands https://leetcode.com/problems/letter-combinations-of-a-phone-number
13 53 200 Maximum Subarray Number of Islands 46.5% 46.8% Easy Medium 0.04299340685592046 0.04526299408355752 https://leetcode.com/problems/maximum-subarray https://leetcode.com/problems/number-of-islands
14 5 53 Longest Palindromic Substring Maximum Subarray 29.5% 46.5% Medium Easy 0.035860192879893796 0.04299340685592046 https://leetcode.com/problems/longest-palindromic-substring https://leetcode.com/problems/maximum-subarray
15 4 5 Median of Two Sorted Arrays Longest Palindromic Substring 29.6% 29.5% Hard Medium 0.034565653112280895 0.035860192879893796 https://leetcode.com/problems/median-of-two-sorted-arrays https://leetcode.com/problems/longest-palindromic-substring
16 33 4 Search in Rotated Sorted Array Median of Two Sorted Arrays 34.5% 29.6% Medium Hard 0.0287009496170278 0.034565653112280895 https://leetcode.com/problems/search-in-rotated-sorted-array https://leetcode.com/problems/median-of-two-sorted-arrays
17 146 33 LRU Cache Search in Rotated Sorted Array 33.2% 34.5% Medium Medium 0.028411001832779885 0.0287009496170278 https://leetcode.com/problems/lru-cache https://leetcode.com/problems/search-in-rotated-sorted-array
18 349 146 Intersection of Two Arrays LRU Cache 62.5% 33.2% Easy Medium 0.016239981598488416 0.028411001832779885 https://leetcode.com/problems/intersection-of-two-arrays https://leetcode.com/problems/lru-cache
19 79 349 Word Search Intersection of Two Arrays 35.6% 62.5% Medium Easy 0.014883688014740005 0.016239981598488416 https://leetcode.com/problems/word-search https://leetcode.com/problems/intersection-of-two-arrays
20 215 79 Kth Largest Element in an Array Word Search 55.4% 35.6% Medium Medium 0.008759180089881562 0.014883688014740005 https://leetcode.com/problems/kth-largest-element-in-an-array https://leetcode.com/problems/word-search
21 39 215 Combination Sum Kth Largest Element in an Array 56.1% 55.4% Medium Medium 0.005715934396440999 0.008759180089881562 https://leetcode.com/problems/combination-sum https://leetcode.com/problems/kth-largest-element-in-an-array
22 387 39 First Unique Character in a String Combination Sum 53.4% 56.1% Easy Medium 0.00418541994270691 0.005715934396440999 https://leetcode.com/problems/first-unique-character-in-a-string https://leetcode.com/problems/combination-sum
23 387 First Unique Character in a String 53.4% Easy 0.00418541994270691 https://leetcode.com/problems/first-unique-character-in-a-string