This repository aims to solve and create new problems from different spheres of coding. A path to help students to get access to solutions and discuss their doubts.
We can solve it O(n^2) using that technique also. Like if we partition the array into two groups [i.....j] and [j+1......n] and Now for each j=1 to j=n-1 we can call find the maximum profit which will be the addition of the profits of these groups and at the last return the maximum.
We can also solve it in O(n) time by using DP by storing the maxprofit at each index from left and from right as well. Thus, we don't need to compute it again and again. The following is the code for this approach.
Screenshots(Attach 2 screenshots of your own input and output) -
Attach here
![Uploading Screenshot 2021-10-07 at 3.33.42 PM.png…]()
Checklist:
Eg - If your code follow the below guidelines. Kindly change [] to [x]
All the conditions should be fulfilled for considering your code for merging -
[x] I have mentioned the question as comment in my solution file.
[x] My code follows the guidelines of this project.
[x] I have performed a self-review of my own code.
[x] I have commented my code.
[x] My code gives the correct output.
[x] I confirm that I have not copied the code from anywhere. In case its found that I have copied even after successful merge then I can be banned from the repository and hacktoberfest.
[x] I affirm that I strictly follow contributing guidelines and code of conduct.
Issue Id you have worked upon -
Issue #290
Briefly explain your program logic -
We can solve it O(n^2) using that technique also. Like if we partition the array into two groups [i.....j] and [j+1......n] and Now for each j=1 to j=n-1 we can call find the maximum profit which will be the addition of the profits of these groups and at the last return the maximum.
We can also solve it in O(n) time by using DP by storing the maxprofit at each index from left and from right as well. Thus, we don't need to compute it again and again. The following is the code for this approach.
Screenshots(Attach 2 screenshots of your own input and output) -
Attach here ![Uploading Screenshot 2021-10-07 at 3.33.42 PM.png…]()
Checklist:
Eg - If your code follow the below guidelines. Kindly change [] to [x]
All the conditions should be fulfilled for considering your code for merging -
[x] I have mentioned the question as comment in my solution file.
[x] My code follows the guidelines of this project.
[x] I have performed a self-review of my own code.
[x] I have commented my code.
[x] My code gives the correct output.
[x] I confirm that I have not copied the code from anywhere. In case its found that I have copied even after successful merge then I can be banned from the repository and hacktoberfest.
[x] I affirm that I strictly follow contributing guidelines and code of conduct.