0% found this document useful (0 votes)
8 views1 page

Python Coding Challenges and Solutions

The document outlines a series of Python programming questions that cover various topics including list manipulation, string rotation, bubble sort modifications, and matrix operations. Each question provides a specific task to be accomplished, such as rotating a list, finding maximum sums of subarrays, and generating substrings. Additionally, it includes examples to clarify the expected input and output for some of the tasks.

Uploaded by

vesujakr
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)
8 views1 page

Python Coding Challenges and Solutions

The document outlines a series of Python programming questions that cover various topics including list manipulation, string rotation, bubble sort modifications, and matrix operations. Each question provides a specific task to be accomplished, such as rotating a list, finding maximum sums of subarrays, and generating substrings. Additionally, it includes examples to clarify the expected input and output for some of the tasks.

Uploaded by

vesujakr
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

Python Programming Questions

1. Rotate List Left by K Positions


Write a function that rotates a list to the left by k positions without using extra space.

2. Maximum Sum of Subarrays of Size 3


Find the maximum sum among all contiguous subarrays of size 3 in a given list.

3. Check if One String is Rotation of Another


Write a function to check if one string is a rotation of another.
Example: Input: "waterbottle" and "erbottlewat" → Output: True

4. Count Swaps in Bubble Sort


Modify bubble sort to return the number of swaps performed to sort a list.
Example: Input: [5, 1, 4, 2, 8] → Output: 5

5. Find All Pairs with Given Sum


Use a set to find all unique pairs in a list that sum up to a given value.
Example: Input: [1, 5, 7, -1, 5], target = 6

6. Generate All Substrings


Generate all substrings of a given string.
Example: Input: 'aababcdb'

7. Sum of boundary elements in a given matrix.

8. Print right angle triangle pattern.

9. Print Elements of a List in Reverse Order - Write a recursive function that prints elements
of a list in reverse order. Example: print_reverse([1, 2, 3, 4]) → 4 3 2 1

You might also like