# Tag Info

### Dynamic programming with Fibonacci

A few things: Naming: It's neither Fibonaci, nor febonani, nor fibonanci it's ...
• 25k
Accepted

### Find the Nth number divisible by only 2,3,5, or 7

No, not $O(n)$. Not even close. I'll get back to this later though. First, the code: It's a little difficult to tell what your loop logic is. curr is getting ...
• 18.3k

### Performance of dynamic Fibonacci generator and dead rabbits

With regard to your time complexity: With your calculation of the nth Fibonacci number, you could do it in $O(1)$ time by using the relation: F_n = \left\lfloor \frac{\varphi^n}{\sqrt{5}} + \...
• 3,760
Accepted

### DP example for "Power of Two" in Python

There are some major issues with your approach, the major one being that it is going to terribly break down for really large numbers. But if you want to go with it, here are a couple of improvements: ...
• 6,512

### Yet another Fibonacci number generator

Assuming you're using the current c++ standard, since you don't specify in your question. Prefer stoi to atoi. ...

### Yet another Fibonacci number generator

Is this a generator or a calculator? Generators are objects that behave like iterators, yielding the next value on every call. ...
• 6,078
Accepted

### Counting Increasing Subsequences of size K recursive

Concept You have called this a "Longest Increasing Subsequence" problem, but it's not, is it? It's counting all possible sequences of a specific length, not just the longest. As a result, I think you ...
• 96.8k
Accepted

### Change-making problem with specific constraints

1. Review The function coinChange carries out three tasks: (i) read the input; (ii) solve the problem; (iii) print the solution. This makes it hard to test, ...
• 49.2k

### DP example for "Power of Two" in Python

If someone were to say: isPowerOf2(9223372036854775808) what would your function do? For a start, it will end up with an array of a very, very large size.... that ...
• 96.8k
Accepted

### Dynamic Programming: Fibonacci-like recurrence relation

Recursive Solution Code-wise, I see no issues. The one thing I'd point out is that it might be clearer to name your functions A and ...
• 18.3k

### Project Euler #15: counting paths through a 20 × 20 grid

#include <cstdio> If your goal is to write C++, you're really off to a bad start using the C standard I/O library. ...
• 8,666
Accepted

### Justify text from a file using a LaTeX method

You should have a look at Python's official style-guide, PEP8. One of its recommendations is to use PascalCase for class names and ...
• 40.6k

### Dynamic programming with Fibonacci

@Vogel612 has already mentioned all major defects and areas of improvement in your code. I want to talk about one more thing: Your package naming is horrible. You are using ...
• 10.6k

### Coin Change: Minimum number of coins

Currently, your code is next to unreadable. The variable names are too cryptic. Names like den and S don't tell anything about ...
• 5,643
Accepted

### Coin Change: Minimum number of coins

Bug You code is currently too simplistic. All it does is make change from the highest denomination possible. It fails on the following input: ...
• 28.4k

The loop ...
• 53.8k
Accepted

### Project Euler #15: counting paths through a 20 × 20 grid

Why are you using unsigned short? I presume the answer is somewhere along the lines of worrying about memory usage. There isn't a problem with that, but given that ...
• 5,721
Accepted

### Find smallest number of squares that sum to a number

Not an review, but an extended comment: I don't know how this solution can be optimized. The expected solution is radically different, and is based on a couple of theorems from number theory. You ...
• 53.8k

### find longest common substring in space O(n)

PEP 8 You are following most of the PEP 8 style guidelines. One that you are breaking is method names should be snake_case; your function should be named ...
• 31.2k
Accepted

### Printing the number of ways a message can be decoded

Your code performs one recursion per character and recursion depth is limited. For long inputs, your code will raise RecursionError: maximum recursion depth exceeded...
• 2,277

### Recursive solution of ordered Coin Combinations II (CSES)

Normally I do a design review first, then review the code itself. This time I’m going to switch it around. Code review Before I get into review this code, I just have to say that the sample solution ...
• 8,666
Accepted

### House-coloring optimization challenge

I do have a lot of comments, but I find your solution pretty good. The algorithm makes sense, and your comments make it easy to follow. The function is closer to a computation than a search, so I ...
• 142k

### Yet another Fibonacci number generator

using namespace std using namespace std; Count the number of characters you use with this (twenty) and compare to the ...
• 20.8k

### Obtaining a target number only using the operations ×2, ×3, and +1

For each i = 0...number, your method stores a std::list containing the complete sequence of intermediate numbers from ...
• 22.4k
Accepted

### Project Euler #14: Longest Collatz Sequence starting point

Integer Division In Python, 10 / 2 is equal to 5.0, not 5. Python has the integer division ...
• 31.2k

### Three-machine proportionate flow shop problem with unequal machine

Missing methods The posted code is missing the schedule_left() and CreateOutputFile() method. Style you should always ...
• 50k

### Coin Change: Minimum number of coins

Everything is in main. It's called main. It's not called everything. You have written no ...
• 25.2k

### Find the Nth number divisible by only 2,3,5, or 7

This Code Review, so let us review your code, before proceeding to questions and optimisations. Code and style review Choose better names – According to python style guide, PEP8, you should use <...
• 11.5k