전체 글137 CodeSignal [46/60] electionsWinners Problem: Elections are in progress! Given an array of the numbers of votes given to each of the candidates so far, and an integer k equal to the number of voters who haven't cast their vote yet, find the number of candidates who still have a chance to win the election. The winner of the election must secure strictly more votes than any other candidate. If two or more candidates receive the same .. 2020. 5. 27. CodeSignal [45/60] buildPalindrome Problem: Given a string, find the shortest possible string which can be achieved by adding characters to the end of initial string to make it a palindrome. Example For st = "abcdc", the output should be buildPalindrome(st) = "abcdcba". -Summary- 1. loop 을 돌며, i 부터 끝 index의 string이 palindrom 인지 아닌지를 확인한다. 2. 만약 palindrom이 아니라면 palindrom 이 나올때까지 search 한다. 3. palindrom substring을 만나면, nonPalindrom.. 2020. 5. 27. CodeSignal [44/60] findEmailDomain Problem: An email address such as "John.Smith@example.com" is made up of a local part ("John.Smith"), an "@" symbol, then a domain part ("example.com"). The domain name part of an email address may only consist of letters, digits, hyphens and dots. The local part, however, also allows a lot of different special characters. Here you can look at several examples of correct and incorrect email addr.. 2020. 5. 26. CodeSignal [43/60] isBeautifulString Problem: A string is said to be beautiful if each letter in the string appears at most as many times as the previous letter in the alphabet within the string; ie: b occurs no more times than a; c occurs no more times than b; etc. Given a string, check whether it is beautiful. Example For inputString = "bbbaacdafe", the output should be isBeautifulString(inputString) = true. This string contains .. 2020. 5. 26. CodeSignal [42/60] bishopAndPawn Problem: Given the positions of a white bishop and a black pawn on the standard chess board, determine whether the bishop can capture the pawn in one move. The bishop has no restrictions in distance for each move, but is limited to diagonal movement. Check out the example below to see how it can move: Example For bishop = "a1" and pawn = "c3", the output should be bishopAndPawn(bishop, pawn) = t.. 2020. 5. 26. CodeSignal [41/60] digitDegree Problem: Let's define digit degree of some positive integer as the number of times we need to replace this number with the sum of its digits until we get to a one digit number. Given an integer, find its digit degree. Example For n = 5, the output should be digitDegree(n) = 0; For n = 100, the output should be digitDegree(n) = 1. 1 + 0 + 0 = 1. For n = 91, the output should be digitDegree(n) = 2.. 2020. 5. 26. 이전 1 ··· 15 16 17 18 19 20 21 ··· 23 다음