-
-
Notifications
You must be signed in to change notification settings - Fork 35.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Smallest Common Multiple – Optimized Advanced Solution #19572
Conversation
Made 2 minor improvement to the advanced solution: 1. The original advanced solution used `Math.max` and `Math.min` against the supplied array, this causes the values in the supplied array to be compared twice. If we use sort instead, the values are only compared once and we can target the max and min values using an index. This is more efficient. 2. The original solution caused `lcm(min, min + 1)` to be evaluated twice. By incrementing `min` the first time we run `lcm` we avoid this duplication and also by taking advantage of the prefix increment operator ++ in the while loop, we trim a line.
@@ -156,16 +156,15 @@ Note: If the array only has two elements, then the `for` loop never gets used an | |||
function smallestCommons(arr) { | |||
|
|||
// range | |||
let min = Math.min.apply(null, arr); | |||
let max = Math.max.apply(null, arr); | |||
const sorted = arr.sort((a,b) => a > b) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @arcdev1,
Thank you for opening for PR.
Just to clarify, Math.min()
and Math.max()
both have time complexity of O(n). The complexity of .sort()
for small arrays is O(n2) and for big array is O(nlogn), both of which are greater than O(n), so technically using .sort()
is slower than using min and max together.
Since we have small arrays in the tests, it doesnt really matter so, using .sort()
is fine.
The other content that you've added make the code concise so its fine, but do fix the sort method.
Hi @ezioda004, you are right I recommend we change back to let min = Math.min(...arr);
let max = Math.max(...arr); Here's a working example: What do you think? |
Honestly, for sorting two elements, I would lean towards the sort and do the following which uses destructuring. This increases readability and makes the code more concise at the same time.
|
Also, this is just my opinion, but the Advanced solution probably should use ES6 syntax throughout, so:
becomes:
|
@RandellDawson Destructuring is great, but honestly I've seen campers and everyone struggle with it, for the sake of readability I'd avoid that. I like the alt spread syntax, thats ES6 as well. |
But this is the advanced solution, where we get to show the campers how to use the advanced features such as destructuring. The spread syntax could be confusing if you have never seen it before also. The destructuring could easily be explained in the explanation of the solution along with links to existing FCC challenges for destructuring arrays. I believe we need to get some consensus from the senior contributors as to what Advanced means, so we have clearer idea of when we really should be changing these existing working solutions at all. I think the original solution was fine and seems quite readable to me. It could maybe use a few extra bullet points in the explanation regarding the apply method, but otherwise it seems fine to me. My point here is we need some clearer definitions (which do not currently exist) for when to leave things alone. A thousand people could look at this solution and come up with a "better" solution. We just need to define what makes a beginner, intermediate, and advanced solution different. We should discuss this outside of Github. |
@RandellDawson There are already existing guidelines. Old solutions had note:
So with spread syntax he's merely updating the syntax as spread syntax is quite common these days so updating to newer syntax IMO is fine.
I agree we should discuss this and have a guideline on that but here it's not relevant since the advanced solution already exists and he's simply updating it. |
The key word is "better". That is subjective and I believe we need at least 2-3 others to agree on if a change makes something "better". Is it better in terms of readability, time complexity, memory complexity, conciseness?
Destructuring arrays is also quite common these days and is also a newer syntax IMO. Personally, I like the code written with the apply method, because I actually remember the first time I ever came across the apply method used was from this very Guide article. I exposed me to learn about something totally new and it is not covered in the current curriculum that I am aware of. These older solutions were vetted and reviewed many times over before we got involved. There is a reason why they have not changed, because they are fine the way they are (IMO). |
My two cents. @ezioda004 I don't think @RandellDawson 's suggestion violates the following:
My interpretation of that guidance is that we should not add a new solution (e.g. an "Advanced Solution 2" alongside the original Advanced Solution). I don't think changing the original one to use destructuring would violate that rule. I think the trade-offs are:
I think given the constraints on the array and the nature of the function, the performance impact is not worth basing our decision on. The question of what is "clean" or "advanced" or even "better" is quite subjective. So, I think we're left with the question of "what is more suitable to our audience, given what we are trying to teach?" Do we have any empirical evidence we can use to answer that question? |
This is why I think we need to get some senior contributors to weigh in on this issue.
Out of curiosity, what makes you believe the destructured line is less performant for a two element array? |
|
The very fact that we are even debating about this change, means there is a difference in opinion that needs some other way to settle it I have had major issues with that site. I have ran tests on it before and it gives very misleading information and it is easy to break. Plus, what array is being fed into it? I doubt it is a two element array. |
It is a two element array. I built that in order to formulate a response to a comment from @ezioda004 on the commit. See thread here: #19572 (comment) My instinct was that |
@RandellDawson Good points about
The array is @arcdev1 Good points as well. |
Again we are talking about a two element array. A fraction of a fraction of a second difference. When it is that close, I typically go with keeping it concise and the destructured version definitely does that without two lines of Math.min(...arr), Math.max(...arr). We have different opinions here and because that, we need to table this until we can get others involved. These same kinds of debates occur very often on the forum when someone posts "Is this a better solution than the Guide?". There will be 20 people chime in with their "best" solution. They may all be right. I think all of the solutions presented here are great, but the question is do we really need to change the original solution and I say it is not necessary. That does not mean I think the suggestions made are not good solutions. We just need a formal process of review when it comes to posting "best" solutions in the Guide. I hope you understand what I am getting at here. If we have an agreed upon practice (i.e. 2 out of 3 reviewers say the change is good), then I will be fine even if I am the 1 reviewer who disagreed. |
I believe the original solution runs As for the |
Oh yes, I forgot about that part. Yes, your suggestion is an improvement there for sure. |
So maybe where we are at is that the |
After thinking about this a bit more I will go with whatever @ezioda004 thinks. I think this was a good debate and let's us realize we need a formal review process for this kind of thing. I am going to bow out on this one. |
I'd say updating it with spread syntax is fine. Spread syntax for the most part is syntactic sugar for Sure, you can learn about the behavior of |
@RandellDawson Yes, we should certainly have a discussion about this with higher ups. |
Okay. I think we have agreement I will update the code with the spread operator for FWIW @RandellDawson I really liked your formulation from an aesthetic standpoint and I might have to find a way to use it on something else down the road ;) |
Don't forget to convert the helper functions to arrow syntax. |
Using destructuring in two places (using your main logic) would yield:
The destructuring also avoids creating a temp variable in the gcd function. |
I don't mind destructuring for swapping. Also, just remembered the recursive way of GCD const gcd = (a, b) => b === 0 ? a : gcd(b, a%b); This is quite famous recursive algorithm. |
@RandellDawson I think for the top level function, the signature is already there when its presented to the student, so I don't think we should change that to an arrow function. In general, I'm not a fan of arrow functions in these kind of situations, but that's very much a personal preference thing. Like you though, I'm happy to defer to @ezioda004 on this one. So, @ezioda004 what say you? Option Afunction smallestCommons (arr) {
const gcd = (a, b) => b === 0 ? a : gcd(b, a%b);
const lcm = (a, b) => (a * b) / gcd(a, b);
let [min,max] = arr.sort((a,b)=> a-b);
let currentLCM = min;
while (min < max) {
currentLCM = lcm(currentLCM, ++min);
}
return currentLCM;
}; Option Bfunction smallestCommons (arr) {
let min = Math.min(...arr)
let max = Math.max(...arr)
let currentLCM = min;
while (min < max) {
currentLCM = lcm(currentLCM, ++min);
}
return currentLCM;
};
function lcm (a, b) {
return (a * b) / gcd(a, b);
}
function gcd (a, b) {
return b === 0 ? a : gcd(b, a%b);
} Edit: Moved the helper functions to the global scope in B to stay truer to he original Or something else? |
@arcdev1 Option A looks good to me at first glance. Probably because the function expressions are on top 😅 BTW great article! |
Made the following changes to the advanced code solution: - Converted helper functions to arrow function constants - Simplified comments - Used destructuring and `sort` for `min` and `max`
* section about what configuration management tool (freeCodeCamp#19379) * section about what configuration management tool Add a section to explain in basic words what a configuration management tool mean. Probably anyone visiting this Puppet guide does not know what is Puppet to begin with so I believe it is good to have simple explanation with very basic examples. * Update index.md * Default img display type (freeCodeCamp#19421) * Default img display type Added info about how img elements are rendered for display type by default. * Update index.md * Update declare-a-read-only-variable-with-the-const-keyword.english.md * Guide/packer (freeCodeCamp#19444) * Packer initial * Moved packer to devops * Adding unpacking list elements to variables (freeCodeCamp#19437) * Adding unpacking list elements to variables * fix: indentations * Add solution (freeCodeCamp#19228) Add solution (https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/regular-expressions/match-characters-that-occur-one-or-more-times) * Fixed wording and typos on REACT section (freeCodeCamp#19451) * Fixed wording and typos on REACT section Simplified wording and fixed typos for great clarity in the React section of the index.md. * Simplification of wording in the React Section Fixed a typo in the description section for React * fix: corrected case for virtual DOM * Update index.md (freeCodeCamp#19452) * Update index.md (freeCodeCamp#19453) * docs: add example use cases for expansion cards -added several examples of modern use cases for expansion cards and reasons for utilizing them * Update index.md Added more information to the advantages of compiled languages and to the disadvantages of interpreted languages for a better understanding. * Added new command 'mkdir' (freeCodeCamp#18796) * Add code syntax highlighting Add code highlighting for the code examples in the section "Comparing null and undefined" * Created a guide for the bash ssh command (freeCodeCamp#19450) * Created a guide about the mkdir command * Update index.md * Added a guide for the rm command in bash * Created a new guide for the chmod command * Created the guide for the ssh command * Add note on user names * Fixed last 2 links (freeCodeCamp#19483) Incorrect markdown format had them displaying a broken image link, because the links don't lead to an image. Used normal markdown link format instead. * Fixed last URL (freeCodeCamp#19482) URL was not properly formatted in Markdown, so it was a broken link. Fixed markdown format and link works now. * Text editing with corrections (freeCodeCamp#18513) Grammar/spelling corrections and sentence refactoring, so the text sounds less "translated" and more natural. * Small typo fix (freeCodeCamp#18383) * Fixed broken img link (freeCodeCamp#19484) Just changed from http to https. Before this, the image link did not work. * Typo fix (freeCodeCamp#18386) * Typo fix (freeCodeCamp#18388) * Clears a few details (freeCodeCamp#18391) * Fix text to follow language's syntax (freeCodeCamp#18467) Change the positions of some words so that they are in accordance with the rules of syntax of the Portuguese language. Remove some duplicated text. * Spanish translation fixes (freeCodeCamp#19297) * Fix text to follow portuguese language syntax (freeCodeCamp#18475) Change the positions of some words so that they are in accordance with the rules of syntax of the Portuguese language. Change some translated words back to english for clarity (e.g. "...atribua a ele um valor de *center*" instead of "...atribua a ele um valor de centro "). * Update index.md (freeCodeCamp#19461) * Fix text to follow portuguese language syntax (freeCodeCamp#18481) * Fix text to follow portuguese language syntax (freeCodeCamp#18485) * docs: translate how-to-setup-freecodecamp-locally.md to Portuguese (freeCodeCamp#18540) * Update CONTRIBUTING.md (freeCodeCamp#18617) Atualizando palavra corrijir para corrigir. * Minor portuguese translation fixes (freeCodeCamp#18634) * Improved translation (freeCodeCamp#18908) Corrected a few translations errors. * fix: Corrections in Portuguese translation (freeCodeCamp#18910) * fix: Corrections in Portuguese translation (freeCodeCamp#18913) * fix: Corrections in Portuguese translation (freeCodeCamp#18917) * Improvedo Portuguese translation (freeCodeCamp#19235) * Add translations to titles and fix typo (freeCodeCamp#19250) * Add translation for titles (freeCodeCamp#19252) * Add translation for titles [Portuguese] (freeCodeCamp#19258) * Add translation for titles [Portuguese] (freeCodeCamp#19264) * Update visualize-data-with-a-choropleth-map.portuguese.md (freeCodeCamp#19266) * Update visualize-data-with-a-scatterplot-graph.portuguese.md (freeCodeCamp#19268) * Update adjust-the-tone-of-a-color.english.md (freeCodeCamp#19512) * Added </code> to test text (freeCodeCamp#19498) * Update index.md (freeCodeCamp#19518) * Added code for delete operation on BST (freeCodeCamp#19516) * deadlock in opearting system (freeCodeCamp#19514) * Update add-classes-with-d3.english.md (freeCodeCamp#19508) * Update add-classes-with-d3.english.md * Update add-classes-with-d3.english.md * Update add-classes-with-d3.english.md * added information about parallel computing (freeCodeCamp#19494) added about what is parallel computing, why parallelism, how to parallelize, data and task parallelism etc. * added changes for props (freeCodeCamp#19489) * fix(guide): simplify directory structure * Add translations to titles and fix typo (freeCodeCamp#19262) * fix(ci): fix tests for guide in root (freeCodeCamp#19526) * translated to chinese (freeCodeCamp#18592) * Fixed typo (freeCodeCamp#19532) commeting -> commenting * fix: Corrections in Portuguese translation (freeCodeCamp#18899) * Fixed grammar, added link (freeCodeCamp#19544) * Fixed grammar, added link * fix: minor typo by contributor * Added some missing words and translations (freeCodeCamp#18497) Added some missing words and gave a better translation to rgba meanning, because people could be asking why b is Azul, instead of saying that is blue and then placing the translation to spanish Azul. * Some format and grammar corrections in Spanish (freeCodeCamp#18408) I propose some changes on the grammar and wording to make it more natural sounding * Added a better translation in Description (freeCodeCamp#18498) Have translated first 3 rows of description in a better understanding way. * Changed tag Figura with Figure (freeCodeCamp#18549) Changed the tag Figura with Figure. * Update Spanish translation for negative margin article (freeCodeCamp#18552) * Given a better translation to Instructions (freeCodeCamp#18550) Given a better translation to Instructions * Better translation to last row of instructions (freeCodeCamp#18555) Have given a better translation to part of last row of instructions. * fix example code for CSS Grid article (freeCodeCamp#18563) * Removed the word "da" (freeCodeCamp#19524) It's not necessary the usage of the word "da Web" just "Web" is correct" * removed word "da" from line 10; (freeCodeCamp#19523) * Fixed some portuguese word order erros (freeCodeCamp#19517) Wrong order of the word "element", it must come before the word "a" - line 10 * Update use-html5-to-require-a-field.portuguese.md (freeCodeCamp#19510) Typo on the word "neste", it should be "este" The word "campo" must come before "required" - on line 13 Lost question mark after "obrigatório" - on line 13 Wrong order of the word "de" on line 20 * Change in description + change in headings (freeCodeCamp#19497) * fix: a typo fix to how-to-setup-freecodecamp-locally guide (freeCodeCamp#19563) * Update wording of index.md (freeCodeCamp#19559) Inserted missing words in the article and comments Updated the capitalization of True and False where necessary to maintain consistency with Python syntax * Update index.md (freeCodeCamp#19571) * Update index.md (freeCodeCamp#19580) * fix(guide): Improve java access modifiers (freeCodeCamp#19578) Made several improvements to the current guide on Java access modifiers. * Added hints and solutions to Redux exercises (freeCodeCamp#19576) * added hints and solutions to exercise * added hints and solutions to problem * Update index.md (freeCodeCamp#19556) Splitting the useful links into two sections (Boilerplates and Info References) and adding electron-userland and electron-react-boilerplate as two fairly useful repos any Electron developer might be interested. I'd encourage others to add Vue/Angular boilerplates. Also added a couple tidbits of other info here and there * Responsive Web Design: Added hint to Create a Custom CSS Variable (freeCodeCamp#19605) Added hint to Create a Custom CSS Variable (https://guide.freecodecamp.org/certifications/responsive-web-design/basic-css/create-a-custom-css-variable) * Responsive Web Design: Added hint to Change the Font Size of an Element (freeCodeCamp#19603) Added hint to Change the Font Size of an Element (https://guide.freecodecamp.org/certifications/responsive-web-design/basic-css/change-the-font-size-of-an-element) * Update access-props-using-this.props.spanish.md (freeCodeCamp#18577) * Update use-arrow-functions-to-write-concise-anonymous-functions.english.md * Update write-arrow-functions-with-parameters.english.md * Update use-the-spread-operator-to-evaluate-arrays-in-place.english.md * Update use-destructuring-assignment-to-assign-variables-from-objects.english.md * feat: add React-Context guide article in english (freeCodeCamp#19595) * feat: add React-Context guide article in english * fix: indentation and formatting * Update use-destructuring-assignment-to-assign-variables-from-nested-objects.english.md * A better translation to "colorblind" (freeCodeCamp#18707) I also have made a few minor changes in some sentences, just to sound more natural; and some "tildación" fixes. * Enhaced translation camelCase + wikipediaLink (freeCodeCamp#18711) 1. I replaced 2. I added anchor element to remember camelCase style. * Improving Spanish Translation for how-to-catch-outgoing-emails-locally (freeCodeCamp#18758) * Update how-to-catch-outgoing-emails-locally.md * Update how-to-catch-outgoing-emails-locally.md * Update how-to-catch-outgoing-emails-locally.md Improving translation * Update how-to-catch-outgoing-emails-locally.md * Update how-to-catch-outgoing-emails-locally.md * improve the translation of 'add-flex-superpowers-to-the-tweet-embed.spanish' (freeCodeCamp#18802) * fix(guide): Numbering the notes in the article * Fix(curriculum): Clarify translated title * [Guide] Basic JS: Random numbers within range. Enhancements (freeCodeCamp#19539) * [Guide] Basic JS: Random numbers within range. Enhancements Added code solution, explanation, resources and other minor fixes. * Additional fix; list. * update: created ordered list of calculation * Added D3 solution (freeCodeCamp#19604) * Update index.md * Update index.md * Fix(curriculum): Add the word "структур" to localeTitle after "и" * Added D3 solution to scatterplot challenge (freeCodeCamp#19609) * Update index.md * Update index.md * Added D3 solution (freeCodeCamp#19607) * Update index.md * Update index.md * Fix(curriculum): Replace "ниже" with "здесь" * Functional programming guide (freeCodeCamp#19561) * updates for css3 media queries article, now in proper repo * Requested changes * functional programming article * requested spacing changes * Added solution to Add a Hover Effect to a D3 Element (freeCodeCamp#19606) * Update index.md * Update index.md * fix typo (freeCodeCamp#19640) * fix spelling errors (freeCodeCamp#19616) dinamic - > dynamic * Update add-a-text-alternative-to-images-for-visually-impaired-accessibility.spanish.md (freeCodeCamp#19597) * fix spelling error (freeCodeCamp#19623) * SSH:Move files between servers (freeCodeCamp#18987) * added guidelines to move files between servers * Move and update scp article This commit moves the file to the correct place and updates the format of the content for correctly displaying content. The move is in accordance with the new architecture of where the Guide articles are placed within the repository. * Delete Django change Appears to be leftover from another commit. * Docker:More About Docker containers (freeCodeCamp#19018) * added intorduction to setup AWS S3 in Django project to store static assets and media files * added guidelines to move files between servers * added more commands for docker-containers * Fix text to follow portuguese language syntax (freeCodeCamp#19061) Change the positions of some words to be in accordance with the syntax rules of the Portuguese language. Remove some duplicated text. * fix(coding): update instructions to CSS Flexbox challenge in Portuguese (freeCodeCamp#19065) * Fix text to follow portuguese language syntax Change the positions of some words to be in accordance with the syntax rules of the Portuguese language. * Update use-the-align-items-property-in-the-tweet-embed.portuguese.md * fix(coding): update instructions to CSS Flexbox challenge in Portuguese (freeCodeCamp#19067) * Fix text to follow portuguese language syntax Change the positions of some words to be in accordance with the syntax rules of the Portuguese language. * Update use-the-align-self-property.portuguese.md * Responsive Web Design: Added hint to Inherit Styles from the Body Ele… (freeCodeCamp#19631) * Responsive Web Design: Added hint to Inherit Styles from the Body Element Added hint to Inherit Styles from the Body Element (https://guide.freecodecamp.org/certifications/responsive-web-design/basic-css/inherit-styles-from-the-body-element) * Added Full solution * Update index.md description (freeCodeCamp#19657) Added more description to the definition of computer science. * Improving spanish translation for CONTRIBUTING.md (freeCodeCamp#18684) * Improving spanish translation for CONTRIBUTING.md * Improving and fixing Spanish translation of how-to-catch-outgoing-emails-locally.md file * Removed unwanted reference number (freeCodeCamp#19669) Removed reference number which was of no use. * Fix text to follow portuguese language syntax (freeCodeCamp#19069) Change the positions of some words to be in accordance with the syntax rules of the Portuguese language. * Fix text to follow portuguese language syntax (freeCodeCamp#19079) Change the positions of some words to be in accordance with the syntax rules of the Portuguese language. * Fix text to follow portuguese language syntax (freeCodeCamp#19084) Change the positions of some words to be in accordance with the syntax rules of the Portuguese language. * fix(coding): update instructions to CSS Flexbox challenge in Portuguese (freeCodeCamp#19070) * Fix text to follow portuguese language syntax Change the positions of some words to be in accordance with the syntax rules of the Portuguese language. Change some translated words back to English for clarity of the instructions. * Update use-the-flex-direction-property-to-make-a-column.portuguese.md * fix(coding): update instructions to CSS Flexbox challenge in Portuguese (freeCodeCamp#19083) * Fix text to follow portuguese language syntax Change the positions of some words to be in accordance with the syntax rules of the Portuguese language. * Update use-the-flex-wrap-property-to-wrap-a-row-or-column.portuguese.md * Update description: Deleted redundant code inline (freeCodeCamp#19137) I deleted `<code>dispatch</code>`. I think this is redundant. This is better as _El método de `dispatch`_ * working locally link wasn't working, so I updated it (freeCodeCamp#19140) * working locally link wasn't working, so I updated it * Fixed incorrectly "fixed" link. * Proofread Add Axes to a Visualization spanish.md (freeCodeCamp#19181) Proofread and fixed spacing. * Changed 'before' to 'after' to reflect the intended image insertion p… (freeCodeCamp#19072) * Changed 'before' to 'after' to reflect the intended image insertion point in the code * Changed h2 to main * Fix typos (freeCodeCamp#19685) * Removed reference number (freeCodeCamp#19673) unused reference number * Update Bootstrap 4.1.3 (freeCodeCamp#19507) * Update Bootstrap 4.1.3 Update to 4.1.3 for compiled CSS and JSmin * Added comment about BS version. * Switch to back-ticks for code block (freeCodeCamp#19574) * Update adjust-the-height-of-an-element-using-the-height-property.spanish.md * Updated test text to Spanish And changed CSS rule back to English in the example. Using back-ticks to properly format the code block * Changed CSS rules back to English (freeCodeCamp#19569) * Changed CSS rules back to English CSS rules are the same in Spanish no need to translate them. * Indented code block * Indented code block and use back-ticks * Formatted code block with back-ticks Also updated test text. * fix(guide): Clean up "first-docker-image" (freeCodeCamp#19684) * Fixing typo in a Guide path(freeCodeCamp#19678) (freeCodeCamp#19696) * Fixing typo in a Guide path(freeCodeCamp#19678) * Fix the folder name to be lowercase and separated by hyphens * fix(guide): Clean up Java Collections * Updated CPU images (freeCodeCamp#19688) Previous images using `http`. Replaced with `https` images with creative commons licenses * Language correction (freeCodeCamp#19726) Chinese in Italian is 'Cinese' * Update index.md (freeCodeCamp#19715) * Provide link to S3 documentation (freeCodeCamp#19730) Also, update buket to bucket. * Update index.md (freeCodeCamp#19772) Boolean algebra as it relates to the use of NOT for parenthetic expressions * NOT for parenthetic expressions (freeCodeCamp#19773) Boolean algebra as it relates to the use of NOT for parenthetic expressions * Add link to official ArrayList documentation (freeCodeCamp#19787) * Smallest Common Multiple – Optimized Advanced Solution (freeCodeCamp#19572) * Optimized advanced solution Made 2 minor improvement to the advanced solution: 1. The original advanced solution used `Math.max` and `Math.min` against the supplied array, this causes the values in the supplied array to be compared twice. If we use sort instead, the values are only compared once and we can target the max and min values using an index. This is more efficient. 2. The original solution caused `lcm(min, min + 1)` to be evaluated twice. By incrementing `min` the first time we run `lcm` we avoid this duplication and also by taking advantage of the prefix increment operator ++ in the while loop, we trim a line. * Fixed extra spaces in code block * Incorporated code feedback from freeCodeCamp#19572 Made the following changes to the advanced code solution: - Converted helper functions to arrow function constants - Simplified comments - Used destructuring and `sort` for `min` and `max` * Fixed spacing. * Grammar correction (freeCodeCamp#19961) Deleted "s" in paragraph 1, sentence 2: "A markupS language" * Minor grammar edit. (freeCodeCamp#19943) * Corrected spelling of "available" (freeCodeCamp#19978) * Added outputs for examples (freeCodeCamp#20171) * Update broken links (freeCodeCamp#20280) Removed the single quotes at the end of each link so they work correctly. * Fixed a typo (freeCodeCamp#20329) * Fix incorrect sentence (freeCodeCamp#20315) Fix error in sentence structure * Docs: Modified function declaration example in JS ES6 (freeCodeCamp#20208) * Update css box model (freeCodeCamp#20412) Link was no longer working for the image. Found a new image on same website, GitHub is having a small glitch and not loading the image properly. * Corrected spelling "subtlties" (freeCodeCamp#20402) Corrected spelling "subtlties" to "subtleties" line 16 * Update index.md (freeCodeCamp#20404) Some brief explainations of function used and definations of notation used . * Change var to const (freeCodeCamp#20331) * Added book: JavaScript and JQuery (freeCodeCamp#19011) * Fix typo on `componentWillReceiveProps` (freeCodeCamp#21255) * Update index.md (freeCodeCamp#21252) * Fix(docs): Add text from English version * Fix(guide): Add v-for index documentation * Fix(guide): Add "cd -" to manual * Fix(guide): Add BFS for non-weighted graphs * Fix(guide): Add rounded image example * Fix(guide): Add resources for version control * Fix text to follow portuguese language syntax (freeCodeCamp#19075) Change the positions of some words to be in accordance with the syntax rules of the Portuguese language. * feat(ci): Ensure guide directory structure in CI * fix(guide): Fix directory structure * fix(guide-ci): Reimplement throwing to the CI script * fix(guide-ci): Fix formatting of directory structure * feat(guide-ci): Add frontmatter checks to the guide CI * fix(guide): Fix all frontmatter * fix(guide-ci): Handle uncaught errors * Added a "Why use nodeJS" section (freeCodeCamp#20459) * Added a "Why use nodeJS" section Added a "Why use nodeJS" section which talks about a few advantages of using nodeJS * fix: formatting * Fixed typo (freeCodeCamp#21616) * Fix typos "witht" and "spaguetti" (freeCodeCamp#21649) * Spelling and Grammar Fixes (freeCodeCamp#21542) I fixed some spelling and grammar errors. * Fix title styling typo (freeCodeCamp#21518) Fixing the title to remove the `#` and to be consistent with other article titles. * corrected typos and rephrased sentence (freeCodeCamp#21545) * Update index.md (freeCodeCamp#21488) * Fixed typo in an example (freeCodeCamp#21436) * Fix punctuation marks and articles (freeCodeCamp#20274) * Added example to convert int to binary (freeCodeCamp#20275) * added link to "women who code" (freeCodeCamp#21621) * Fixed naming issue (freeCodeCamp#21604) * Fix misspelled word interchangeably (2), and while (freeCodeCamp#21591) * Added the Industrial Iot Based DDOS attacks (freeCodeCamp#19020) * Adjusted readability of XML simplifications (freeCodeCamp#21052) Adjusted the ordered list of things that are simplified with XML to be easier read and understandable. * Added the text "object-oriented" to article (freeCodeCamp#21642) Also made some grammatical changes * corrected spelling and grammar (freeCodeCamp#21479) * corrected path (freeCodeCamp#23529) * Update use-for-to-create-a-sass-loop.english.md (freeCodeCamp#23815) I did not understand the original lesson of "through" vs "to" upon first reading. Later reading the code below it started to make sense... but I added a bit more to the explanation. * improved <b> tag article (freeCodeCamp#23496) Expanded b tag article to provide greater clarity and additional guidance Replaced example with more appropriate one Removed link to w3schools as info there is out of date and therefore misleading * Delete Blender (freeCodeCamp#22044) * fix(guide): Lowercased 3D and Blender directories so Travis CI tests pass (freeCodeCamp#24167) * fix: mathjax rendering (freeCodeCamp#18468) * fix(guide): Deleted and or moved the directories/files in client/src/guide and client/src/pages... (freeCodeCamp#19732) * fix: remove article from repo root * fix: removed all hidden chars from tests verbiage (freeCodeCamp#19674) * fix: removed all &freeCodeCamp#8203; from tests verbiage * fix: added single quote to start text string * remove single quote from text line * fix: removed the hidden chars in the testStrings * fix: removed hidden chars from testString section * fix: removed hidden chars form testString part * fix: removed hidden chars from testString part * fix: removed hidden chars from testString part * Translation improvements for description and instructions + translation of the challenge seed (freeCodeCamp#19435) * Fixed Header (freeCodeCamp#21263) Changed "##Who invented Linux?" to "## Who invented Linux?" * fix(guide): Lowercased the Tableau and Talend directories in all languages (freeCodeCamp#24240) * typo fixes (freeCodeCamp#21210) * Added use of 'or' (freeCodeCamp#21675) * Update index.md (freeCodeCamp#21704) Added description for C#. * Update index.md (freeCodeCamp#21707) * Update index.md (freeCodeCamp#21773) A simple implementation of class and object in python. * Update index.md (freeCodeCamp#21942) * Closing Parentheses (freeCodeCamp#21481) The parentheses were opened but not closed * Update index.md (freeCodeCamp#22006) Removed " where it is not needed and capitalised 'ide' to show as "IDE" * Update index.md (freeCodeCamp#22032) * Update index.md (freeCodeCamp#23500) * Update index.md (freeCodeCamp#23481) Improved phrasing of lines 10-12 * Update index.md to include ASP Forum link (freeCodeCamp#23452) * Update index.md (freeCodeCamp#23325) Added another reference for Vim info. * Fix typo on CRA's package name (freeCodeCamp#21219) The create-react-app installation npm command has a typo: ```npm install -g react-create-app``` Instead of ```npm install -g create-react-app``` * Update index.md (freeCodeCamp#23239) just made the sentence flow a little bit more. * Index.md update (freeCodeCamp#23228) * [fix] Added articles back which were overwritten in previous commit (freeCodeCamp#24441) * fix(curriculum): quotes in tests (freeCodeCamp#18828) * fix(curriculum): tests quotes * fix(curriculum): fill seed-teardown * fix(curriculum): fix tests and remove unneeded seed-teardown * Fixed spelling and added code keywords for passport strategies challenge (freeCodeCamp#24605) * chore: update codeowners * fix: remove redirect build on dev * Updated index.md (freeCodeCamp#23736) * Update index.md (freeCodeCamp#23702) Added information to line 8 regarding Greyball * Update index.md (freeCodeCamp#23664) added link to wiki * chore: update codeowners for guide * chore: update codeowners * chore: update codeowners * Fix typo: "excercise" => "exercise" (freeCodeCamp#24084) * Fix(docs): Fix Typos in Italian translation (freeCodeCamp#19117) * Feat(docs): create Romanian translation for Contribution Guidelines * Responsive Web Design: Added hint to Attach a Fallback Value to a CSS Variable (freeCodeCamp#19594) Added hint to Attach a Fallback Value to a CSS Variable (https://guide.freecodecamp.org/certifications/responsive-web-design/basic-css/attach-a-fallback-value-to-a-css-variable/) * Fixed Typo Line 64 (freeCodeCamp#19705) Replaced '/' with '.' * Update index.md (freeCodeCamp#19698) * typos and grammar correction for angular cli guide (freeCodeCamp#19762) 'n' added to 'npm' and grammar fix * Update how-to-work-on-guide-articles.md (freeCodeCamp#19740) * add missing semicolon (freeCodeCamp#19796) add missing semicolon * Add link to official String documentation (freeCodeCamp#19797) * Line 14 Missing Hyphen (freeCodeCamp#19763) On line 14, 64 bit should be hyphenated before "long memory addresses." * Added alternative hint to change file permissions (freeCodeCamp#19234) * Mejor traducción (freeCodeCamp#19236) * Update index.md (freeCodeCamp#20583) Cleaned up first para. * Update index.md (freeCodeCamp#20638) More clean up of the rest of the document. Also changed "introspect" to "inspect", as I think that was the intended word. * Update index.md (freeCodeCamp#20616) Cleaned up 5th (and now, 6th) paras. * Update index.md (freeCodeCamp#20593) Cleaned up 2nd and 3rd paras. * Update index.md (freeCodeCamp#21751) Adding a better description of Web accessibility in Portuguese. * Renamed /create-file-with-sepcific-size to /create-file-with-specific-size (freeCodeCamp#23838) * Update index.md (freeCodeCamp#24174) Add New Syntax one line example * Update index.md (freeCodeCamp#24230) Incorrectly spelled word: Organizational and Across were corrected. * Javascript: add solution to hint Match Characters that Occur Zero or … (freeCodeCamp#19231) * Improve formatting of Spanish wireframing article (freeCodeCamp#19220) * Improve translation of Spanish visual hierarchy article (freeCodeCamp#19221) * Improve translation of Spanish Additional JavaScript Resources article (freeCodeCamp#19224) * Update how-to-work-on-coding-challenges.md (freeCodeCamp#19135) * Update how-to-catch-outgoing-emails-locally.md (freeCodeCamp#19133)
Made minor improvements to the advanced solution:
The original advanced solution used
Math.max
andMath.min
against the supplied array, this causes the values in the supplied array to be compared twice. If we usesort
instead, the values are only compared once and we can target themax
andmin
values using an index. This is more efficient.The original solution caused
lcm(min, min + 1)
to be evaluated twice. By incrementingmin
the first time we runlcm
we avoid this duplication and also by taking advantage of the prefix increment operator++min
in thewhile
loop, we trim a line.Update index.md
)master
branch of freeCodeCamp.