-
Notifications
You must be signed in to change notification settings - Fork 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
14-fnzksxl #69
14-fnzksxl #69
Conversation
μμ§ μμ±μ μλμ§λ§ νκ³ ν리뷰λ₯Ό λ΄€λλ° μ λ λ°λ‘ λ¬Έμμ΄μ λ€μ§κ³ νμ§ μμμ΅λλ€!! resultμ μ°μ λ£μΌλ©΄μ boomμ κΈΈμ΄λ§νΌ resultμ λ€μ΄μλ λ¨μ΄μ λΉκ΅ν΄ νλ° λ¬Έμμ΄μ΄ μμΌλ©΄ resultμμ popμ νλ νμμΌλ‘ μ§ννμ΅λλ€!! word = input()
boom = list(input())
result = []
for i in word:
result.append(i)
if result[len(result)- len(boom):len(result)] == boom:
for _ in range(len(boom)):
result.pop()
if result:
print("".join(result))
else :
print("FRULA") |
μ€, μ κ° PR μ°λ©΄μ μΆκ°λ‘ κΈ°μ νλ €κ³ νλ λ°©λ²μ
λλ€! |
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.
1μ°¨ μλ
split κ³Ό joinToString μ μ¬μ©ν΄μ ν΄κ²°νλ €νμΌλ λ©λͺ¨λ¦¬μ΄κ³Ό
fun main() {
val br = BufferedReader(InputStreamReader(System.`in`))
val sentence = br.readLine()
val bomb = br.readLine()
var words = sentence.split(bomb)
while (words.size > 1) {
words = words.joinToString("").split(bomb)
}
val answer = words.joinToString("")
if (answer.isEmpty()) {
println("FRULA")
}
println(words.joinToString(""))
}
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.
μ±κ³΅ kotlin list λ₯Ό μ¬μ©νμ§ μμΌλ λ©λͺ¨λ¦¬ μ΄κ³Ό ν΄κ²°~
import java.io.BufferedReader
import java.io.InputStreamReader
import java.util.Stack
fun main() {
val br = BufferedReader(InputStreamReader(System.`in`))
val sentence = br.readLine()
val bomb = br.readLine()
val stack = Stack<Char>()
for (i in sentence.indices) {
stack.push(sentence[i])
if (stack.size < bomb.length) {
continue
}
if (!isEqual(bomb, stack)) {
continue
}
repeat(bomb.length) { stack.pop() }
}
if (stack.isEmpty()) {
println("FRULA")
return
}
println(stack.joinToString(""))
}
private fun isEqual(bomb: String, stack: Stack<Char>): Boolean {
for (j in bomb.indices) {
if (stack[stack.lastIndex - j] != bomb[bomb.lastIndex - j]) {
return false
}
}
return true
}
@fnzksxl μ¬μ€ μ²μμλ κ°μκ² λμ€λ©΄ λΊ΄μ£Όλ©΄ λλκ±° μλμΌ νλ©΄μ μ§λ€κ° νλ°νκ³ μ΄μ΄μ§λ λΆλΆμ μ²λ¦¬λ₯Ό λͺ»ν΄μ μ½λλ₯Ό λ°κΏλ΄€μ΅λλ€!! |
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.
μ΄λ° νμ΄λ μλ€μ!
λ¬Έμμ΄μ μ λ ₯λ°κ³ μ€νμ λ¬Έμ νλμ© λ£μΌλ©΄μ λ§μ½ μ€νμ΄ μλ λ¬Έμκ° νλ° λ¬Έμλ©΄ μ€νμμ λ½μλ΄κ³ , λ§μ§λ§μ μ€νμ λ¬Έμκ° λ¨μμμΌλ©΄ stack μ μλ λ¬Έμλ€μ μΆλ ₯νκ³ , μλλ©΄ FRULA λ₯Ό μΆλ ₯νλ μ½λμ λλ€!
import sys
input =sys.stdin.readline
S = input().rstrip()
B = input().rstrip()
stack = []
b_len = len(B)
for i in range(len(S)):
stack.append(S[i])
if ''.join(stack[-b_len:]) == B:
for _ in range(b_len):
stack.pop()
if stack :
print(''.join(stack))
else :
print('FRULA')
π λ¬Έμ λ§ν¬
λ¬Έμμ΄ νλ°
βοΈ μμλ μκ°
μ½ 30λΆ?
β¨ μλ μ½λ
ν리뷰 - μ€νμ μ΄μ©ν κ°λ¨ν μκ³ λ¦¬μ¦μλλ€. νλ° λ¬Έμμ΄μ λ€μ§μ΄ μκ°νλ κ² ν€λ½μΈνΈμμ
μ΄ λ¬Έμ λ₯Ό κ°λ¨νκ² μ€λͺ νμλ©΄ λ¬Έμμ΄ λ κ°κ° μ£Όμ΄μ§λλ°, νμ μ£Όμ΄μ§λ λ¬Έμμ΄μ΄ μ μ μ£Όμ΄μ§λ λ¬Έμμ΄μ ν¬ν¨μ΄ λλ©΄
μ κ±°νλ λ¬Έμ μ λλ€.
μμ
λ¬Έμ 쑰건μμ μ£Όμ΄μ§λ λ¬Έμμ΄μ κΈΈμ΄κ° κ½€λ κΈΈκΈ° λλ¬Έμ ν λ²μ μνλ‘ λλ§μ³μΌν©λλ€. λ°λ³΅λ¬Έμ΄ μ΄μ€μΌλ‘ λμκ°λ©΄ μκ° μ΄κ³Ό μ΄μλ‘ λ²νΈ μκ° μμ΄μ.
μμ΄λμ΄λ κ½€ μ½μ΅λλ€.
3-1. λ½μλΈ μΉκ΅¬ == λ€μ§μ νλ° λ¬Έμμ΄ -> append μ ν¨
3-2. λ½μλΈ μΉκ΅¬ != λ€μ§μ νλ° λ¬Έμμ΄ -> λ€μ append
λ μ΄ν΄νκΈ° μ½κ² κ·Έλ¦ΌμΌλ‘ 보μμ£ .
μ΄κΈ°μνμ λλ€ !
μ΄μ λ¬Έμμ΄μ μννλ©΄μ stack λ°°μ΄μ μΆκ°ν΄μ€λλ€. νμ§λ§ ν€ κ°(νλ° λ¬Έμμ΄μ λ§μ§λ§ λ¬Έμ)μ΄ μΆκ°κ° λλ©΄?
νλ° λ¬Έμμ΄μ κΈΈμ΄λ§νΌ pop ν΄μ€λλ€. popμΌλ‘ stackμμ λΉΌμκΈ° λλ¬Έμ μμκ° λ°λμΌ μ λ°μ μμ΄μ!
κ·Έλμ λ€μ§μ νλ° λ¬Έμμ΄κ³Ό λΉκ΅λ₯Ό νλ κ²λλ€.
λ€μ stack λ°°μ΄μ μΆκ°νλ€κ° ν€ κ°μΈ 4λ₯Ό λ§λ¬μΌλ―λ‘ μ κ³Όμ μ λ°λ³΅ν΄μ€λλ€.
μ 체μ½λ
π μλ‘κ² μκ²λ λ΄μ©