diff --git a/code_study/Baekjoon/python/13866.py b/code_study/Baekjoon/python/13866.py new file mode 100644 index 0000000..53b8e7d --- /dev/null +++ b/code_study/Baekjoon/python/13866.py @@ -0,0 +1 @@ +print((lambda x: abs((x[3] + x[0]) - (x[1] + x[2])))(list(map(int, input().split())))) \ No newline at end of file diff --git a/code_study/Baekjoon/swift/1509.swift b/code_study/Baekjoon/swift/1509.swift new file mode 100644 index 0000000..605f5a5 --- /dev/null +++ b/code_study/Baekjoon/swift/1509.swift @@ -0,0 +1,36 @@ +func solve() -> Int { + guard let input = readLine() else { return -1 } + let str = Array(input) + let N = str.count + + var isPalindrom: [[Bool]] = Array(repeating: Array(repeating: false, count: N), count: N) + + for len in 1...N { + for start in 0...N-len { + let end = start + len - 1 + + if (len == 1) || (len == 2 && str[start] == str[end]) || (str[start] == str[end] && isPalindrom[start+1][end-1]) { + isPalindrom[start][end] = true + } + } + } + + var dp: [Int] = Array(repeating: 2501, count: N) + + for end in 0..