Skip to content

Conversation

@greypz
Copy link
Contributor

@greypz greypz commented Apr 13, 2025

Hi i added the sollution and used kadane's algorithm however in kadane's algorithm negative values are also acceptable.
wouldn't a simpler sum algorithm be better for this kind of problem?

Copy link
Owner

@codewithdhruba01 codewithdhruba01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What’s Good

  • User Input Loop implemented correctly with exit condition (x).
  • Kadane’s Algorithm is used properly to compute maximum subarray sum.
  • Handles empty input gracefully.
  • Outputs result in the correct format: Maximum subarray sum = X.

Minor Issues

  • Input Type Not as Per Prompt
    Prompt expects input as non-negative integer characters, e.g. ['1', '2', '3'], but current implementation directly accepts integers including negatives like -2, -1.

    📌 Solution: Accept inputs as string characters, validate they are digits, then convert to integers.

  • No Explicit Character to Integer Conversion Step
    As per the requirement, character list should be explicitly converted to integers using list(map(int, char_list)).

    📌 Currently, input is already integer — so this step is implicitly skipped.


Your solution is almost complete and works great logically — just a small adjustment to input format will make it fully aligned with the problem statement. Great job overall! 👍

@greypz
Copy link
Contributor Author

greypz commented Apr 14, 2025

Thanks a lot for detailed feedback, i've adjusted the code acording to your feedback

Copy link
Owner

@codewithdhruba01 codewithdhruba01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All Good

@codewithdhruba01 codewithdhruba01 merged commit 740b058 into codewithdhruba01:master Apr 14, 2025
@codewithdhruba01
Copy link
Owner

1 mistake Comment on this issue and explain the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants