0% found this document useful (0 votes)
14 views3 pages

Python Leetcode Practice

The document outlines a series of coding challenges categorized into easy and medium levels, each with a brief description, relevant concepts, and example inputs and outputs. The challenges include reversing a string, finding the maximum in a list, counting vowels, and more complex tasks like removing duplicates and rotating a list. Each task is linked to a corresponding LeetCode problem for further reference.

Uploaded by

Phaneendra Reddy
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views3 pages

Python Leetcode Practice

The document outlines a series of coding challenges categorized into easy and medium levels, each with a brief description, relevant concepts, and example inputs and outputs. The challenges include reversing a string, finding the maximum in a list, counting vowels, and more complex tasks like removing duplicates and rotating a list. Each task is linked to a corresponding LeetCode problem for further reference.

Uploaded by

Phaneendra Reddy
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

🟢 Easy Level

1️⃣ Reverse a String


🔗 LeetCode #344 – Reverse String

Write a function that reverses a string. The input string is given as an array of characters.
🧠 Concepts: loops, string indexing, lists
📘 Example:

Input: ["h","e","l","l","o"]
Output: ["o","l","l","e","h"]

2️⃣ Find Maximum in a List


🔗 LeetCode #414 – Third Maximum Number (you can simplify it to find just the max or
second max)
🧠 Concepts: loops, conditionals, list traversal
📘 Example:

Input: [3, 2, 1]
Output: 3

3️⃣ Count Vowels in a String


🔗 LeetCode #709 – To Lower Case (use this as a base; modify to count vowels)
🧠 Concepts: loops, conditionals, string indexing
📘 Example:

Input: "Hello"
Output: 2

4️⃣ Sum of Elements in a List


🔗 LeetCode #1480 – Running Sum of 1d Array

Calculate running sum; similar logic can be used to get total sum.
🧠 Concepts: loops, accumulation, lists
📘 Example:

Input: [1,2,3,4]
Output: [1,3,6,10]

5️⃣ Palindrome Check


🔗 LeetCode #125 – Valid Palindrome

Check if a string reads the same backward as forward.


🧠 Concepts: string indexing, slicing, conditionals
📘 Example:

Input: "madam"
Output: True

🟡 Medium Level
6️⃣ Find Second Largest Element
🔗 LeetCode #414 – Third Maximum Number (can adapt to find 2nd largest)
🧠 Concepts: loops, comparisons, lists
📘 Example:

Input: [10, 20, 4, 45, 99]


Output: 45

7️⃣ Remove Duplicates from a List


🔗 LeetCode #26 – Remove Duplicates from Sorted Array

Remove duplicates in-place and return the new length.


🧠 Concepts: lists, conditionals, loops
📘 Example:

Input: [1,1,2]
Output: [1,2]

8️⃣ Merge Two Lists Alternately


🔗 LeetCode #21 – Merge Two Sorted Lists

Same merging concept, but you can do it alternately instead of by sorting.


🧠 Concepts: lists, loops, functions

9️⃣ Frequency of Each Character


🔗 LeetCode #387 – First Unique Character in a String (relies on frequency counting)
🧠 Concepts: loops, dictionaries, string indexing
📘 Example:

Input: "banana"
Output: {'b':1, 'a':3, 'n':2}

🔟 Rotate a List
🔗 LeetCode #189 – Rotate Array

Rotate an array of n elements to the right by k steps.


🧠 Concepts: list slicing, loops, modulo
📘 Example:

Input: [1,2,3,4,5,6,7], k = 3
Output: [5,6,7,1,2,3,4]

You might also like