We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
The issue is not the language itself, but the boilerplate code they use to process test cases (JavaScript run in Node.js is actually generally speaking fast af). For some reason they use parseInt() instead of the Number constructor to parse integers, which slows it down A LOT.
This causes an issue when coders know JavaScript but aren't very familiar with Node.js, as they don't feel confident enough to change the surrounding code. I've been where you are though, and so I want to give you the help I never got.
Below is a full solution in JavaScript, including the test case parsing code. Hopefully, you can look at the code and learn from it:
Minimum Swaps 2
You are viewing a single comment's thread. Return to all comments →
The issue is not the language itself, but the boilerplate code they use to process test cases (JavaScript run in Node.js is actually generally speaking fast af). For some reason they use parseInt() instead of the Number constructor to parse integers, which slows it down A LOT.
This causes an issue when coders know JavaScript but aren't very familiar with Node.js, as they don't feel confident enough to change the surrounding code. I've been where you are though, and so I want to give you the help I never got.
Below is a full solution in JavaScript, including the test case parsing code. Hopefully, you can look at the code and learn from it: