목록string (20)
N
168. Excel Sheet Column Title Given an integer columnNumber, return its corresponding column title as it appears in an Excel sheet. For example: A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -> 28 ... Example 1: Input: columnNumber = 1 Output: "A" Example 2: Input: columnNumber = 28 Output: "AB" Example 3: Input: columnNumber = 701 Output: "ZY" Example 4: Input: columnNumber = 2147483647 Output: ..
https://programmers.co.kr/learn/challenges 코딩테스트 연습 기초부터 차근차근, 직접 코드를 작성해 보세요. programmers.co.kr 주어진 문자열에서 숫자가 영단어로 이뤄진 경우 숫자로 바꿔 리턴하면 된다. for문을 통해 s의 문자를 확인한다. zero, one, eight, nine 처럼 영단어의 시작이 다른 숫자와 겹치지 않기 때문에 해당하는 숫자(문자열로 저장)를 answer에 저장한다. 그리고 단어의 길이 - 1을 i에 더해 다음 문자를 읽도록 한다. 만약 two, three, four, five와 같이 중복되는 경우 substr()함수를 이용해 한번 더 검사하여 해당하는 숫자를 저장한다. 마찬가지로 i에 단어의 길이 - 1을 더한다. 리턴값은 int형이..
58. Length of Last Word Given a string s consists of some words separated by spaces, return the length of the last word in the string. If the last word does not exist, return 0. A word is a maximal substring consisting of non-space characters only. Example 1: Input: s = "Hello World" Output: 5 Example 2: Input: s = " " Output: 0 Constraints: 1 token){ str.push_back(token); } if(str.empty()){ ret..
28. Implement strStr() Implement strStr(). Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. Clarification: What should we return when needle is an empty string? This is a great question to ask during an interview. For the purpose of this problem, we will return 0 when needle is an empty string. This is consistent to C's strstr() and Java's ..
14. Longest Common Prefix Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string "". Example 1: Input: strs = ["flower","flow","flight"] Output: "fl" Example 2: Input: strs = ["dog","racecar","car"] Output: "" Explanation: There is no common prefix among the input strings. Constraints: 1
13. Roman to Integer Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 For example, 2 is written as II in Roman numeral, just two one's added together. 12 is written as XII, which is simply X + II. The number 27 is written as XXVII, which is XX + V + II. Roman numerals are usually written largest to smallest from ..
6. ZigZag Conversion The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P L S I I G Y I R And then read line by line: "PAHNAPLSIIGYIR" Write the code that will take a string and make this conversion given a number of rows: string convert(string s, int numRows); Exam..
https://programmers.co.kr/learn/courses/30/lessons/59047 코딩테스트 연습 - 이름에 el이 들어가는 동물 찾기 ANIMAL_INS 테이블은 동물 보호소에 들어온 동물의 정보를 담은 테이블입니다. ANIMAL_INS 테이블 구조는 다음과 같으며, ANIMAL_ID, ANIMAL_TYPE, DATETIME, INTAKE_CONDITION, NAME, SEX_UPON_INTAKE는 각각 동물의 아이디 programmers.co.kr STRING DATA를 다루는 문제. 와일드 카드인 %를 이용해 'el'이 들어가는 개의 이름을 조회하면 된다. SELECT ANIMAL_ID, NAME FROM ANIMAL_INS WHERE NAME LIKE "%EL%" AND ANI..