# Tag Info

-2

class Solution { HashMap<String, Integer> memo = new HashMap<String, Integer>(); public int solve(int[] coins, int amount, int startFrom) { //0\$left, so we can reach 1 way if(amount == 0) return 1; //already -ve amount means this combination wont work if(startFrom < 0 || amount < 0) return 0; /...

1

Is that creating a temporary multi-dimensional array just to get the extents? It looks like the test code creates a multi-array of doubles with 30 * 30 * 30 * 30 * 2 * 5 * 10 elements... if my math is right that's a ~618MB memory allocation to copy 7 numbers. D: If we're already using the boost::detail namespace, we may as well just copy what boost does to ...

0

Let's put a FULLTEXT index in the middle of the algorithm. It is likely to be faster than other techniques since it is effectively an inverted index of word=>sentence; this can be used for names of both diseases and biomarkers. Furthermore, it can handle multi-word names. Parse the XML, put one sentence per row into the table. That will be only about ...

1

Assuming that you decide to retain _check_parameters(), here's an illustration of some alternative techniques for organizing a complex boolean check. (1) The isinstance() function will take a tuple of types, so you can do some consolidation. (2) If you need to check for None and check for types, you can do it all in one shot. (3) Some of your checks were ...

2

Your code is clearly organized and well presented, but it suffers from a number of problems, from the trivial to the profound. var i = 0 is never used and doesn't need to be there. safety: There's no check for bad input. pascal(2,1) will happily java.lang.StackOverflowError. Your code indicates a lack of familiarity with the Scala Standard Library. ...

2

Bug: short string Consider reverse("", 1). Code attempts s[-1] which leads to undefined behavior (UB). len = 0; s[(len - 1) - (1-1)] // UB Bug: long string Pedantic: Code fails for huge strings longer than INT_MAX. Use size_t, not int. Alternative // left points to left-most character // right points to right-most + 1 character static void rev(...

1

The big thing that jumped out to me was how you seem to be treating Haskell lists like Java... Arrays? (I haven’t used Java since... 2006?) If you’re repeatedly fiddling with the elements at the end of lists, you’re probably doing something wrong. I’m not sure what the complexity of this all is, but I think it might be something like $\mathcal{O}(m^2n^2)$ ...

Top 50 recent answers are included