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