Skip to content

Conversation

@jungmyunggi
Copy link
Collaborator

문제

Type Info
Time Complexity O(N^3)
Space Complexity O(N^3)
Algorithm 백트래킹, 브루트포스
Data Structure x

Constraints

  • 1 <= s.length <= 20
  • s consists of digits only.

Edge Case

x

풀이

n = 문자열 s의 길이
if(n이 12보다 크다면) return []
if(n이 4보다 작다면) return []

result = []

funtion isVaild(분할된 문자열){
  if(문자열의 길이가 1이고 값이 0인경우) return true
  if(문자열의 시작이 0인경우) return false
  if(문자열의 값이 255보다 작은경우) return true
  return false
}
// 점찍는 위치
for(i1 은 1부터 n-2까지){
  part1 = 문자열 시작부터 i1까지
  isVaild가 false면 continue
  for(i2 는 i1+1부터 n-1까지){
    part2 = 문자열 i1부터 i2까지
    isVaild가 false면 continue
    for(i3 는 i2+1부터 n까지){
      part3 = 문자열 i2부터 i3까지
      isVaild가 false면 continue
      part4 = 문자열 i3부터 끝까지
      isVaild가 false면 continue
      result.push("part1.part2.part3.part4")
      }
    }
return result
}


어려웠던 점

  • for문을 3개 사용하지 않고 문자열을 나누는 법을 모르겠음

알게된 점

  • x

@jungmyunggi jungmyunggi merged commit 60ca4e8 into main Jan 2, 2025
2 checks passed
@BangDori BangDori deleted the jungmyunggi/restore-ip-addresses branch January 10, 2025 01:46
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