-
Notifications
You must be signed in to change notification settings - Fork 13k
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
code: added Typescript and Javascript examples #196
Conversation
Not sure whether these formats meet the requirement. If everything is okay I will continue to transcribe more:-)
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
I've finished transcribing |
codes/javascript/chapter_computational_complexity/time_complexity.js
Outdated
Show resolved
Hide resolved
codes/javascript/chapter_computational_complexity/time_complexity.js
Outdated
Show resolved
Hide resolved
codes/javascript/chapter_computational_complexity/time_complexity.js
Outdated
Show resolved
Hide resolved
codes/javascript/chapter_computational_complexity/time_complexity.js
Outdated
Show resolved
Hide resolved
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.
Thanks! Please address the comments.
All addressed @krahets |
Thanks! You can press the |
codes/typescript/chapter_computational_complexity/time_complexity.ts
Outdated
Show resolved
Hide resolved
codes/javascript/chapter_computational_complexity/time_complexity.js
Outdated
Show resolved
Hide resolved
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.
Some unaddressed comments are found.
Here |
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.
Several unaddressed comments in time_complexity.md
.
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.
Thank you @RiverTwilight for your clear code. It seems good and only has a small flaw.
And lack one part in the time_complexity.md:
=== "JavaScript"
js title="worst_best_time_complexity.js"
=== "TypeScript"
typescript title="worst_best_time_complexity.ts"
Please add it, thank you!
codes/typescript/chapter_computational_complexity/time_complexity.ts
Outdated
Show resolved
Hide resolved
codes/typescript/chapter_computational_complexity/time_complexity.ts
Outdated
Show resolved
Hide resolved
codes/typescript/chapter_computational_complexity/time_complexity.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Justin Tse <xiefahit@gmail.com>
…ity.js Co-authored-by: Justin Tse <xiefahit@gmail.com>
…ity.ts Co-authored-by: Justin Tse <xiefahit@gmail.com>
…ity.ts Co-authored-by: Justin Tse <xiefahit@gmail.com>
Co-authored-by: Justin Tse <xiefahit@gmail.com>
Co-authored-by: Justin Tse <xiefahit@gmail.com>
…ity.ts Co-authored-by: Justin Tse <xiefahit@gmail.com>
Co-authored-by: Justin Tse <xiefahit@gmail.com>
Co-authored-by: Justin Tse <xiefahit@gmail.com>
Co-authored-by: Justin Tse <xiefahit@gmail.com>
Co-authored-by: Justin Tse <xiefahit@gmail.com>
@justin-tse @krahets Missing |
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.
Thank you @RiverTwilight for your contribution!
The shuffle method has a little problem, which could not generate the true random data, you could check it in Will It Shuffle?
You could check one of the shuffle methods in wiki
Btw, I have updated the code, feel free to check it.
After updated, the random data are:
Thank you.
codes/javascript/chapter_computational_complexity/worst_best_time_complexity.js
Outdated
Show resolved
Hide resolved
codes/javascript/chapter_computational_complexity/worst_best_time_complexity.js
Outdated
Show resolved
Hide resolved
codes/typescript/chapter_computational_complexity/worst_best_time_complexity.ts
Outdated
Show resolved
Hide resolved
codes/typescript/chapter_computational_complexity/worst_best_time_complexity.ts
Outdated
Show resolved
Hide resolved
} | ||
// 随机打乱数组元素 | ||
for (let i = 0; i < n; i++) { | ||
let r = Math.floor(Math.random() * n); |
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.
let r = Math.floor(Math.random() * n); | |
let r = Math.floor(Math.random() * (i + 1)); |
/* 查找数组 nums 中数字 1 所在索引 */ | ||
function findOne(nums) { | ||
for (let i = 0; i < nums.length; i++) { | ||
if (nums[i] == 1) { |
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.
if (nums[i] == 1) { | |
if (nums[i] === 1) { |
} | ||
// 随机打乱数组元素 | ||
for (let i = 0; i < n; i++) { | ||
let r = Math.floor(Math.random() * n); |
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.
let r = Math.floor(Math.random() * n); | |
let r = Math.floor(Math.random() * (i + 1)); |
/* 查找数组 nums 中数字 1 所在索引 */ | ||
function findOne(nums: number[]): number { | ||
for (let i = 0; i < nums.length; i++) { | ||
if (nums[i] == 1) { |
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.
if (nums[i] == 1) { | |
if (nums[i] === 1) { |
Co-authored-by: Justin Tse <xiefahit@gmail.com>
Thanks very much! @justin-tse The code references in the doc have been updated. |
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.
@RiverTwilight Thank you for your contribution.
Not sure whether these formats meet the requirement. If everything is okay I will continue to transcribe more:-)
If this PR is related to coding or code translation, please fill out the checklist.