Conversation
for more information, see https://pre-commit.ci
content/extraProblems.json
Outdated
|
|
||
| { | ||
| "uniqueId": "usaco-1445", | ||
| "name": "It's Mooin' Time", | ||
| "url": "https://usaco.org/index.php?page=viewproblem2&cpid=1445", | ||
| "source": "Bronze", | ||
| "difficulty": "Easy", | ||
| "isStarred": false, | ||
| "tags": ["Complete Search"], | ||
| "solutionMetadata": { | ||
| "kind": "internal" | ||
| } | ||
| }, |
There was a problem hiding this comment.
is this not already somewhere in guide? i would expect it to be at least
There was a problem hiding this comment.
i thought it was but ig not, its in monthlies but i couldnt find metadata anywhere
There was a problem hiding this comment.
https://usaco.guide/bronze/intro-sets#problem-usaco-1445 :P
always good to do a search of the repo first for this typa thing
There was a problem hiding this comment.
oh 😭 i did not know you could do that mb.
Wait why is this hard??? Ig it needs maps knowledge but does that constitute it for a hard??
|
|
||
| ## Implementation | ||
|
|
||
| **Time Complexity:** $\mathcal{O}(26N)$ |
There was a problem hiding this comment.
maybe use a constant
There was a problem hiding this comment.
where would I write C = 26, representing the numbers of letters.
Ig pure numbers is bad but i js thought since it alr kinda represents the # of letters.
There was a problem hiding this comment.
maybe mention in the explanation that while the time is technically O(N), the factor of 26 is significant
| // Test each possible modifications plus the original character that was in the | ||
| // string This makes sure that the original counts of the string is restored | ||
| // afterwards | ||
| for (char mod = 'a'; mod <= 'z' + 1 && !done; mod++) { |
There was a problem hiding this comment.
i feel like this part of the code could be slightly more 'elegant' (e.g. why is done here? can't you just reset to original after the loop?)
in a similar vein, could loop over i - 2 to i, tho it doesn't matter too much
There was a problem hiding this comment.
wym loop over i - 2 to i??
I can modify my comment to explain it better or recode it.
The main rational behind it was that it was shorter code... :| instead of having to manually test the regular posiiton, each modification basically does the modification so i could test every single modification + the original one which would modify it back to the original position.
If this is better, i could also rewrite the for loop so that it does every character once, (starts at letter + 1 in ascii, loops 26 times and do % 26 to get the current letter)
There was a problem hiding this comment.
ok not necessarily looped but a lot of code is kind of repeated
edi code is pretty clean in this regard: https://usaco.org/current/data/sol_prob3_bronze_dec24.html
Co-authored-by: Justin Ji <68484800+eysbutno@users.noreply.github.com>
|
Still need to fix the explanation a bit, not perfect but lmk if its a little bit clearer. |
Added logic to update character frequencies and insert answers based on conditions.
Place an "x" in the corresponding checkbox if it is done or does not apply to this pull request.