File size: 1,870 Bytes
f9adcbf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
[
    {
        "code": "def is_palindrome(s):\n    \"\"\"Check if string is palindrome\"\"\"\n    s = s.lower().replace(' ', '')\n    return s == s[::-1]",
        "language": "python",
        "task": "boilerplate",
        "description": "Palindrome checker with normalization"
    },
    {
        "code": "def merge_sorted_lists(list1, list2):\n    \"\"\"Merge two sorted lists\"\"\"\n    result = []\n    i, j = 0, 0\n    \n    while i < len(list1) and j < len(list2):\n        if list1[i] < list2[j]:\n            result.append(list1[i])\n            i += 1\n        else:\n            result.append(list2[j])\n            j += 1\n    \n    result.extend(list1[i:])\n    result.extend(list2[j:])\n    return result",
        "language": "python",
        "task": "boilerplate",
        "description": "Merge two sorted lists efficiently"
    },
    {
        "code": "def find_duplicates(arr):\n    \"\"\"Find duplicate elements in array\"\"\"\n    seen = set()\n    duplicates = set()\n    \n    for item in arr:\n        if item in seen:\n            duplicates.add(item)\n        seen.add(item)\n    \n    return list(duplicates)",
        "language": "python",
        "task": "boilerplate",
        "description": "Find duplicates using sets"
    },
    {
        "code": "def reverse_words(sentence):\n    \"\"\"Reverse words in a sentence\"\"\"\n    words = sentence.split()\n    return ' '.join(reversed(words))",
        "language": "python",
        "task": "boilerplate",
        "description": "Reverse word order in sentence"
    },
    {
        "code": "def count_vowels(text):\n    \"\"\"Count vowels in text\"\"\"\n    vowels = 'aeiouAEIOU'\n    return sum(1 for char in text if char in vowels)",
        "language": "python",
        "task": "boilerplate",
        "description": "Count vowels efficiently"
    }
]