Skip to content

322. Coin Change#52

Open
colorbox wants to merge 1 commit into
mainfrom
322
Open

322. Coin Change#52
colorbox wants to merge 1 commit into
mainfrom
322

Conversation

@colorbox

Copy link
Copy Markdown
Owner

Comment thread 322/step2.cpp
int coinChange(vector<int>& coins, int amount) {
vector<int> coin_nums(amount + 1, numeric_limits<int>::max());
coin_nums[0] = 0;
for (int to_coins = 1; to_coins <= amount; ++to_coins) {

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

coinsだと、合計値を指すのか枚数を指すのかが不明瞭になるので別の名前を使うべきだった

Comment thread 322/step1.cpp
public:
int coinChange(vector<int>& coins, int amount) {
vector<long> coin_nums(amount + 1, numeric_limits<long>::max());
coin_nums[0] = 0;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

coin_numsは、コインの金額と解釈される可能性もありそうなので、num_coinsmin_num_coinsあたりがいいかなと思いました。

Comment thread 322/step1.cpp
/*

Time Comprexity: O(n * m) (n: amount, m: coinsの長さ)
Space Complexity: O(n)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

こちらをご確認ください

Hiroto-Iizuka/coding_practice#26 (comment)

Comment thread 322/step1.cpp
int coinChange(vector<int>& coins, int amount) {
vector<long> coin_nums(amount + 1, numeric_limits<long>::max());
coin_nums[0] = 0;
for (long i = 0; i <= amount; ++i) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

long はデータモデルによってビット数が変わります。
https://ja.wikipedia.org/wiki/64%E3%83%93%E3%83%83%E3%83%88#64%E3%83%93%E3%83%83%E3%83%88%E3%83%87%E3%83%BC%E3%82%BF%E3%83%A2%E3%83%87%E3%83%AB
原則避けたほうが無難だと思います。代わりに int64_t を使うことをお勧めいたします。

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants