Files
LeetCode-Questions-CompanyWise/quora_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

27 lines
2.7 KiB
CSV

ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link
923,3Sum With Multiplicity,35.7%,Medium,2.764795138719407, https://leetcode.com/problems/3sum-with-multiplicity
855,Exam Room,43.1%,Medium,1.610689085571983, https://leetcode.com/problems/exam-room
525,Contiguous Array,42.8%,Medium,0.4565830324245594, https://leetcode.com/problems/contiguous-array
297,Serialize and Deserialize Binary Tree,47.5%,Hard,0.3967767600825713, https://leetcode.com/problems/serialize-and-deserialize-binary-tree
498,Diagonal Traverse,48.2%,Medium,0.3533581913127385, https://leetcode.com/problems/diagonal-traverse
437,Path Sum III,47.2%,Medium,0.3499312788602187, https://leetcode.com/problems/path-sum-iii
1053,Previous Permutation With One Swap,48.5%,Medium,0.20067069546215116, https://leetcode.com/problems/previous-permutation-with-one-swap
1027,Longest Arithmetic Sequence,53.4%,Medium,0.11122563511022437, https://leetcode.com/problems/longest-arithmetic-sequence
780,Reaching Points,29.4%,Hard,0.1040197878075301, https://leetcode.com/problems/reaching-points
390,Elimination Game,44.5%,Medium,0.0922312242160336, https://leetcode.com/problems/elimination-game
1329,Sort the Matrix Diagonally,78.4%,Medium,0.08584868273025201, https://leetcode.com/problems/sort-the-matrix-diagonally
113,Path Sum II,46.7%,Medium,0.08136403462264583, https://leetcode.com/problems/path-sum-ii
380,Insert Delete GetRandom O(1),47.5%,Medium,0.08108897817576358, https://leetcode.com/problems/insert-delete-getrandom-o1
852,Peak Index in a Mountain Array,71.6%,Easy,0.07347604683062181, https://leetcode.com/problems/peak-index-in-a-mountain-array
162,Find Peak Element,43.3%,Medium,0.07194178450299923, https://leetcode.com/problems/find-peak-element
253,Meeting Rooms II,45.7%,Medium,0.06712677912083971, https://leetcode.com/problems/meeting-rooms-ii
452,Minimum Number of Arrows to Burst Balloons,49.6%,Medium,0.06234705801852781, https://leetcode.com/problems/minimum-number-of-arrows-to-burst-balloons
14,Longest Common Prefix,35.4%,Easy,0.038247071811121705, https://leetcode.com/problems/longest-common-prefix
15,3Sum,26.8%,Medium,0.025200613617298306, https://leetcode.com/problems/3sum
31,Next Permutation,32.6%,Medium,0.022799505676746757, https://leetcode.com/problems/next-permutation
39,Combination Sum,56.1%,Medium,0.012215135595650004, https://leetcode.com/problems/combination-sum
48,Rotate Image,56.7%,Medium,0.010933053508947611, https://leetcode.com/problems/rotate-image
560,Subarray Sum Equals K,43.9%,Medium,0.00407664649376343, https://leetcode.com/problems/subarray-sum-equals-k
198,House Robber,42.0%,Easy,0.003611415987216383, https://leetcode.com/problems/house-robber
1,Two Sum,45.6%,Easy,0.000785823780173602, https://leetcode.com/problems/two-sum