-
Notifications
You must be signed in to change notification settings - Fork 35
Zero and one parents problem solution #1
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
base: master
Are you sure you want to change the base?
Conversation
hyfi06
left a comment
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 comments
| const findNodesWithZeroAndOneParents = (parentChildPairs) => { | ||
| // Parents | ||
| let parents=[]; | ||
| parentChildPairs.map((Parents) => { |
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.
Usa mejor usa otro nombre para el atributo del callback del map. Recuerda usar camelcase. Estrictamente no son solo Patrents es una tupla de padre e hijo.
| // Childrens | ||
| let childrends=[]; | ||
| let childrendsMoreThanOneParent =[]; | ||
| parentChildPairs.map((Childrends) => { |
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.
si tu variable es parentChildPairs usa mejor parentChildPair para referirte a un elemento del array en el map.
| let zeroParents = []; | ||
| parents.map((Parents) => { | ||
| if (!(childrends.includes(Parents))) | ||
| zeroParents.push(Parents); | ||
| }); |
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.
Mejor usa filter
| let exactlyOneParent = []; | ||
| childrends.map((Childrends) => { | ||
| if (!(childrendsMoreThanOneParent.includes(Childrends))) | ||
| exactlyOneParent.push(Childrends); | ||
| }); |
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.
Mejor usa filter
No description provided.