Hey guys, I did the project based upon the partitioning problem. Basically it checks whether an array can be partitioned in two equal parts or not. I made a DP based solution for it with time complexity and space complexity both O(N*sum(arr)). According to the the course ethics, I should not share my entire code so trust me on the complexity part.
Now my problem, is that I found the question on leetcode and when I submitted by DP solution it did get accepted but as usual in leetcode they gave the results of my relative performance as well. I was pretty much shocked seeing it because it said that I have performed better than 11% coders in terms of time taken and 16% in terms of space used. Please if anybody can suggest how can I take these numbers up to at least 60% or 75% because I am not being able to understand what more can be done after improving using DP. Iâll probably not end up including them but still if anybody can suggest further improvements I will be grateful.
Hey, I dont have a solution to your problem yet, I am writing to give you just a piece of advice. You can share the link to the Leetcode Problem here so that other users in the forum can check your problem and help you with it.
As requested: here is my project notebook. It is based on the LeetCode problem âNetwork-Delay-Timeâ, but slightly different in a few points:
I define a source node as input variable, because this seemed necessary and interesting to me (specially if there is a cycle or different possible source nodes).
And my solution uses the graph-class and recursion. I like the graph-class, but for being able to use it in the Jovian-Testing evaluate_test_cases function, I had to wrap the graph-class in another function, which requires num_nodes and edges and source as input variables. Otherwise I wouldnât have been able to define testcases (based on these three variables num_nodes and edges and source).
The problem I chose was Search a 2D Matrix from LeetCode, where you need to determine whether a target value is inside a m x n matrix containing integers sorted in ascending order. My notebook can be found here. The optimization used is straightforward, but nonetheless effective. You may test my code by copy-pasting it to the LeetCode link.
Hopefully some of you will find my solution helpful.
Hey there, I have problem with the evaluate_test_case function, trying to test my code, it gives me: TypeError: list indices must be integers or slices, not str.
But when I test my code without the evaluate_test_case I have no problem, I tried with different code and still gives the same errorâŚ
This is a piece of my code, and seems to be OK
> for i in range(0, len(price)):
> S[i] = 1
> j = i - 1
> while (j >= 0) and (price[i] >= price[j]):
> S[i] += 1
> j -= 1
> return S
Guys⌠I want some feedback!?
Arenât the expected output and actual output same though they are not in order!?
then why evaluation comes fail?!
Note: Practicing backtracking problems!(permutations)