LeetCode-Questions-CompanyWise/lyft_1year.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

26 lines
2.9 KiB
Plaintext

ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link
735,Asteroid Collision,41.0%,Medium,1.473090540195022, https://leetcode.com/problems/asteroid-collision
238,Product of Array Except Self,60.1%,Medium,1.0067649782470638, https://leetcode.com/problems/product-of-array-except-self
365,Water and Jug Problem,30.6%,Medium,0.8801037398580485, https://leetcode.com/problems/water-and-jug-problem
981,Time Based Key-Value Store,53.1%,Medium,0.8180951326968029, https://leetcode.com/problems/time-based-key-value-store
158,Read N Characters Given Read4 II - Call multiple times,33.8%,Hard,0.752091950433346, https://leetcode.com/problems/read-n-characters-given-read4-ii-call-multiple-times
716,Max Stack,42.6%,Easy,0.6330336058902137, https://leetcode.com/problems/max-stack
127,Word Ladder,29.6%,Medium,0.1667080439422554, https://leetcode.com/problems/word-ladder
642,Design Search Autocomplete System,44.7%,Hard,0.16312782492496253, https://leetcode.com/problems/design-search-autocomplete-system
426,Convert Binary Search Tree to Sorted Doubly Linked List,59.1%,Medium,0.09352605801082346, https://leetcode.com/problems/convert-binary-search-tree-to-sorted-doubly-linked-list
109,Convert Sorted List to Binary Search Tree,47.7%,Medium,0.08701137698962977, https://leetcode.com/problems/convert-sorted-list-to-binary-search-tree
76,Minimum Window Substring,34.6%,Hard,0.05473322196089386, https://leetcode.com/problems/minimum-window-substring
304,Range Sum Query 2D - Immutable,38.6%,Medium,0.054527987071175225, https://leetcode.com/problems/range-sum-query-2d-immutable
91,Decode Ways,24.7%,Medium,0.03673102791879485, https://leetcode.com/problems/decode-ways
1060,Missing Element in Sorted Array,54.5%,Medium,0.017429635135283658, https://leetcode.com/problems/missing-element-in-sorted-array
23,Merge k Sorted Lists,40.2%,Hard,0.016108271385328228, https://leetcode.com/problems/merge-k-sorted-lists
10,Regular Expression Matching,26.8%,Hard,0.01609764684284749, https://leetcode.com/problems/regular-expression-matching
567,Permutation in String,44.4%,Medium,0.014947961435873182, https://leetcode.com/problems/permutation-in-string
88,Merge Sorted Array,39.4%,Easy,0.011986958032982505, https://leetcode.com/problems/merge-sorted-array
48,Rotate Image,56.7%,Medium,0.011428695823622754, https://leetcode.com/problems/rotate-image
20,Valid Parentheses,39.0%,Easy,0.009170695326061695, https://leetcode.com/problems/valid-parentheses
253,Meeting Rooms II,45.7%,Medium,0.008079219870546493, https://leetcode.com/problems/meeting-rooms-ii
349,Intersection of Two Arrays,62.5%,Easy,0.00725034896230682, https://leetcode.com/problems/intersection-of-two-arrays
146,LRU Cache,33.2%,Medium,0.004600353139061353, https://leetcode.com/problems/lru-cache
17,Letter Combinations of a Phone Number,46.8%,Medium,0.0044018999217624675, https://leetcode.com/problems/letter-combinations-of-a-phone-number