Skip to content
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

feat: add bfs and dfs for JS and TS #377

Merged
merged 9 commits into from
Feb 24, 2023
Merged

feat: add bfs and dfs for JS and TS #377

merged 9 commits into from
Feb 24, 2023

Conversation

zhuoqinyue
Copy link
Contributor

If this PR is related to coding or code translation, please read the contribution guideline, fill out the checklist, and paste the console outputs to the PR.

  • I've tested the code and ensured the outputs are the same as the outputs of reference codes.
  • I've checked the codes (formatting, comments, indentation, file header, etc) carefully.
  • The code does not rely on a particular environment or IDE and can be executed on a standard system (Win, macOS, Ubuntu).

@vercel
Copy link

vercel bot commented Feb 21, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated
hello-algo ⬜️ Ignored (Inspect) Feb 24, 2023 at 5:10PM (UTC)

@zhuoqinyue zhuoqinyue changed the title Add bfs and dfs for JS and TS feat: add bfs and dfs for JS and TS Feb 23, 2023
@zhuoqinyue
Copy link
Contributor Author

hey, K sir. It seems that you foget to check this PR? @krahets

@krahets
Copy link
Owner

krahets commented Feb 23, 2023

The PR related to JS and TS is to be reviewed by @justin-tse.

@zhuoqinyue
Copy link
Contributor Author

OK.

Copy link
Contributor

@justin-tse justin-tse left a comment

Choose a reason for hiding this comment

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

@zhuoqinyue Thank you for the clean code.

  1. We are used to adding a blank line in the final.
  2. In TypeScript, most of the time, less is better, we can use Type inference automatically.

codes/javascript/chapter_graph/graph_bfs.js Outdated Show resolved Hide resolved
codes/javascript/chapter_graph/graph_dfs.js Outdated Show resolved Hide resolved
codes/typescript/chapter_graph/graph_bfs.ts Outdated Show resolved Hide resolved
codes/typescript/chapter_graph/graph_dfs.ts Outdated Show resolved Hide resolved
codes/typescript/chapter_graph/graph_bfs.ts Outdated Show resolved Hide resolved
codes/typescript/chapter_graph/graph_bfs.ts Outdated Show resolved Hide resolved
codes/typescript/chapter_graph/graph_bfs.ts Outdated Show resolved Hide resolved
codes/typescript/chapter_graph/graph_dfs.ts Outdated Show resolved Hide resolved
codes/typescript/chapter_graph/graph_dfs.ts Outdated Show resolved Hide resolved
codes/typescript/chapter_graph/graph_dfs.ts Outdated Show resolved Hide resolved
@zhuoqinyue
Copy link
Contributor Author

I've updated it.
But what I'm confused about is why not type constraints on variables in TS.
Are you worried that there will be some null or other types here? @justin-tse

@krahets krahets merged commit 2d421de into krahets:main Feb 24, 2023
@krahets krahets added the code Code-related label Feb 24, 2023
@krahets
Copy link
Owner

krahets commented Feb 24, 2023

Hi @zhuoqinyue ! Could you unify the format of the functions in this PR to

function hashingSearchLinkedList(map: Map<number, ListNode>, target: number): ListNode | null {
...

Now the codes are copied and pasted automatically to the docs based on the recognition by the regular expressions, so we're wondering about a consistent naming style for all the functions and classes.

@zhuoqinyue
Copy link
Contributor Author

zhuoqinyue commented Feb 24, 2023

OK.
Use function declarations instead of function expressions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code Code-related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants