LeetCode-Questions-CompanyWise/tencent_2year.csv
Krishna Kumar Dey fb5f78b55e
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)

```
2023-04-01 11:07:49 +05:30

2.8 KiB

1IDTitleAcceptanceDifficultyFrequencyLeetcode Question Link
2256Paint House52.1%Easy0.03172360722570897https://leetcode.com/problems/paint-house
3143Reorder List37.1%Medium0.025870945598649286https://leetcode.com/problems/reorder-list
433Search in Rotated Sorted Array34.5%Medium0.0200182839715896https://leetcode.com/problems/search-in-rotated-sorted-array
51143Longest Common Subsequence58.4%Medium0.019772173115579716https://leetcode.com/problems/longest-common-subsequence
6394Decode String50.0%Medium0.0182820448374491https://leetcode.com/problems/decode-string
721Merge Two Sorted Lists53.5%Easy0.014012111332134735https://leetcode.com/problems/merge-two-sorted-lists
8227Basic Calculator II36.9%Medium0.01239941490503826https://leetcode.com/problems/basic-calculator-ii
9543Diameter of Binary Tree48.4%Easy0.011898606798495848https://leetcode.com/problems/diameter-of-binary-tree
10121Best Time to Buy and Sell Stock50.5%Easy0.00846879565300311https://leetcode.com/problems/best-time-to-buy-and-sell-stock
11240Search a 2D Matrix II43.2%Medium0.0075829747244553335https://leetcode.com/problems/search-a-2d-matrix-ii
12136Single Number65.5%Easy0.006445166968713385https://leetcode.com/problems/single-number
1376Minimum Window Substring34.6%Hard0.006231520398723243https://leetcode.com/problems/minimum-window-substring
14287Find the Duplicate Number55.5%Medium0.005501320434837602https://leetcode.com/problems/find-the-duplicate-number
15206Reverse Linked List62.5%Easy0.005257021452801617https://leetcode.com/problems/reverse-linked-list
16153Sum26.8%Medium0.004940992758742591https://leetcode.com/problems/3sum
17160Intersection of Two Linked Lists40.6%Easy0.004901369939720486https://leetcode.com/problems/intersection-of-two-linked-lists
18169Majority Element58.7%Easy0.004706444738837472https://leetcode.com/problems/majority-element
19215Kth Largest Element in an Array55.4%Medium0.003902443976931749https://leetcode.com/problems/kth-largest-element-in-an-array
204Median of Two Sorted Arrays29.6%Hard0.003900160950094767https://leetcode.com/problems/median-of-two-sorted-arrays
218String to Integer (atoi)15.4%Medium0.0037925521897059712https://leetcode.com/problems/string-to-integer-atoi
2256Merge Intervals39.3%Medium0.0034728286335985107https://leetcode.com/problems/merge-intervals
231Two Sum45.6%Easy0.003278422738041615https://leetcode.com/problems/two-sum
2420Valid Parentheses39.0%Easy0.0023005704055949323https://leetcode.com/problems/valid-parentheses
255Longest Palindromic Substring29.5%Medium0.002279333142507479https://leetcode.com/problems/longest-palindromic-substring
26190Reverse Bits39.8%Easy0.0018316700789167337https://leetcode.com/problems/reverse-bits