목록string (3)
어흥
문제 링크: www.hackerrank.com/challenges/palindrome-index/problem?utm_campaign=challenge-recommendation&utm_medium=email&utm_source=24-hour-campaign Palindrome Index | HackerRank Determine which character(s) must be removed to make a string a palindrome. www.hackerrank.com 1. 주의할 점 - 삭제를 할 경우, 반으로 나눴을 때를 기준으로 왼쪽 or 오른쪽에 있는 원소를 삭제할 수 있다 - 어느쪽을 삭제해도 상관없는 경우를 조심한다(아래에 TC 존재) #1 1 cbbcb Answer : 4 2. 구현..
문제 링크: www.hackerrank.com/challenges/two-strings/problem?h_l=interview&playlist_slugs%5B%5D=interview-preparation-kit&playlist_slugs%5B%5D=dictionaries-hashmaps Two Strings | HackerRank Given two strings, you find a common substring of non-zero length. www.hackerrank.com 1. 주의할 점 - 문제를 잘 읽자 - KMP 알고리즘을 사용하지 않아도 된다 2. 구현 - 3가지 방법으로 접근했지만 성공한것은 1개 뿐 (1) Set, 시간복잡도: O(N^2*M^2) -> TLE(4/8 성공) - s1의 ..
1. 사용방법: 변수 2개 사용(String, 다른 변수) 2. 간단한 예시 let name = "어흥" let msg = "My name is \(name)!" print(msg) 3. 응용 예시 (Alert, 랜덤함수 사용) class ViewController: UIViewController { var curVal = 0 override func viewDidLoad(){ // } @IBAction func hello(_sender:Any){ let randomPrice = arc4random_uniform(10000)+1 // 1~10000사이의 랜던 숫자 curVal = Int(randomPrice)//randomPrice가 uInt형태기 때문에 형변환 let msg = "현재 물품의 가격은 \..