-
-
Notifications
You must be signed in to change notification settings - Fork 18
Closed
Labels
good first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is neededquestionFurther information is requestedFurther information is requested
Description
“For a given array ‘X’ consisting of non-negative integer characters, find the contiguous subarray with the maximum sum.”
Write a Python program that takes an array X consisting of non-negative integer characters (e.g. ['1', '3', '2']) and finds the contiguous subarray with the maximum sum.
Note: You’ll need to convert characters to integers before processing.
This is a variation of the classic Kadane’s Algorithm problem, but with character input.
Requirements:
- Convert the character array (e.g.
['1', '2', '3']) into an integer array. - Use Kadane’s Algorithm or a similar efficient method to find the maximum sum of a contiguous subarray.
- Print the maximum sum.
- Comment your code for better understanding.
Example / Test Cases:
# Test Case 1:
# Input: ['2', '4', '1', '3']
# Converted Input: [2, 4, 1, 3]
# Output: Maximum subarray sum = 10
# Test Case 2:
# Input: ['5', '0', '2', '1']
# Converted Input: [5, 0, 2, 1]
# Output: Maximum subarray sum = 8
# Test Case 3:
# Input: ['1', '0', '0', '1']
# Output: Maximum subarray sum = 2
# Test Case 4:
# Input: ['0', '0', '0']
# Output: Maximum subarray sum = 0📌 Acceptance Criteria:
- Code must be in Python.
- Step : Go to Interview-Questions Folder : then Create a File: max-subarray-char-input.py
- Include sample input/output in comments.
- Follow clean naming conventions and Python formatting guidelines.
🛠️ How to Work on This Issue:
-
Comment on this issue to get it assigned.
-
Once assigned, create a new branch from the main branch:
git checkout -b feature/max-subarray-char-input
-
Write your code, test it thoroughly.
-
Commit your changes:
git commit -m "Add Python program to find max subarray sum from char array input" -
Push your branch to GitHub:
git push origin feature/max-subarray-char-input
Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is neededquestionFurther information is requestedFurther information is requested