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

[Week5] 김재원 : 바이러스,촌수 계산, 섬의 개수, 전쟁-전투 #23

Merged
merged 6 commits into from
Jun 19, 2022

Conversation

ashwon12
Copy link
Member

📒 Issue Number

linked issue #18


바이러스 : ⭕️
촌수 계산 : ⭕️ 
섬의 개수 : ⭕️ 
전쟁-전투 : ⭕️ 
타겟 넘버 : ❌ 

🔥 특이사항/질문

요번에 DFS/BFS 직접 구현해보면서 제대로 공부 할 수 있었던 거 같아요!!
다른 분들 코드가 궁금하네요!!!!!!!!!!!!!!!!!!

Copy link
Member

@gongdongho12 gongdongho12 left a comment

Choose a reason for hiding this comment

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

페어 잘 활용해보기, 재귀가 싫으면 foldf활용해보기

fun findIsLand(matrix : Array<MutableList<Int>>, visited : Array<Array<Boolean>> ,a : Int,b : Int){
val queue = mutableListOf<Pair<Int,Int>>()
val dx = intArrayOf(-1,0,1,0,-1,-1,1,1)
val dy = intArrayOf(0,-1,0,1,-1,1,-1,1)
Copy link
Member

Choose a reason for hiding this comment

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

dx dy를 List로 했으면 효율적으로 풀 수 있을것 같아요


while(queue.isNotEmpty()){
repeat(queue.size){
val front = queue.removeLast()
Copy link
Member

Choose a reason for hiding this comment

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

큐에 넣어 처리할 거라면 fold 활용해 보시면 좋을것 같아요

@ashwon12 ashwon12 merged commit 4feb0e5 into main Jun 19, 2022
@ashwon12 ashwon12 deleted the week5_jaewon branch June 22, 2022 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants