본문 바로가기

Algorithm/Code Fights (Code Signal)

(68)
Aracade Intro #20 arrayMaximalAdjacentDifference. Algorithm, Codefights, CodeSignal, 코드파이트, 코드시그널, c++ java c# scalar Aracade Intro #20 arrayMaximalAdjacentDifference. Algorithm, Codefights, CodeSignal, 코드파이트, 코드시그널, c++ java c# scalar Q.Given an array of integers, find the maximal absolute difference between any two of its adjacent elements. 주어진 정수 배열 중에서, 인접한 정수끼리 최대의 차이값(절대값) 을 구하여라 e.g.Input -> inputArray = [2, 4, 1, 0]Output -> arrayMaximalAdjacentDifference(inputArray) = 3. ? index 1, 2 -> 4 and 1 -> 3 //..
Aracade Intro #19 AreEquallyStrong. Algorithm, Codefights, CodeSignal, 코드파이트, 코드시그널, c++ java c# scalar Aracade Intro #19 AreEquallyStrong. Algorithm, Codefights, CodeSignal, 코드파이트, 코드시그널, c++ java c# scalar Q. Call two arms equally strong if the heaviest weights they each are able to lift are equal. Call two people equally strong if their strongest arms are equally strong (the strongest arm can be both the right and the left), and so are their weakest arms. Given your and your friend's arms' lift..
Aracade Intro #18 PalindromeRearranging, Codefights, CodeSignal, 코드파이트, 코드시그널, c++ java c# scalar Aracade Intro #18 PalindromeRearranging, Codefights, CodeSignal, 코드파이트, 코드시그널, c++ java c# scalar Given a string, find out if its characters can be rearranged to form a palindrome. 주어진 문자열이, 회문(중간을 기준으로 대칭)자가 될수 있는지 확인한다. e.g. abcba / 다시합창합시다 / bbbbcddcbbbb / 말해말 Input -> "aabb"Output -> palindromeRearranging(inputString) = true We can rearrange "aabb" to make "abba", which is a palindrome. //Pr..
Aracade Intro #17 ArrayChange, Codefights, CodeSignal, 코드파이트, 코드시그널, c++ java c# scalar Aracade Intro #17 ArrayChange, Codefights, CodeSignal, 코드파이트, 코드시그널, c++ java c# scalar Q. You are given an array of integers. On each move you are allowed to increase exactly one of its element by one. Find the minimal number of moves required to obtain a strictly increasing sequence from the input. 정수 배열을 입력받고, 인덱스 순서로 따라올라가는데.. 한 행동에 한개의 숫자 1씩을 증가시킬수 있다. 전부 오름차순이 되도록 해야된다. 전부 오름차순이 되는데 움직인 개수..
Aracade Intro #16 AreSimilar?, Codefights, CodeSignal, 코드파이트, 코드시그널, c++ java c# scalar Aracade Intro #16 AreSimilar?, Codefights, CodeSignal, 코드파이트, 코드시그널, c++ java c# scalar Q. Two arrays are called similar if one can be obtained from another by swapping at most one pair of elements in one of the arrays. Given two arrays a and b, check whether they are similar. 입력받은 두개의 배열 (a, b) 중에서, 어느 한개의 배열에서 한 쌍의 요소들 자리만 바꿔서 (위치는 서로 떨어져 있어도 상관없음) a, b 배열이 같아지면, 비슷하다는 것이 true 이다. e.g. Input -..
Aracade Intro #15 AddBorder, Codefights, CodeSignal, 코드파이트, 코드시그널, c++ java c# scalar Aracade Intro #15 AddBorder, Codefights, CodeSignal Q. Given a rectangular matrix of characters, add a border of asterisks(*) to it. 주어진 글자 매트릭스에다가, 외곽에 * 테두리를 추가하라 e.g. Input -> picture = ["abc", "ded"] Output -> addBorder(picture) = ["*****", "*abc*", "*ded*", "*****"] Input -> ["aa", "**", "zz"] Output ->["****", "*aa*", "****", "*zz*", "****"] 테투리에 * 을 만듦. for 문 2개로 조건문을 만들어서 할까 했는데,1개씩 써서 순..
Aracade Intro #14 AlternatingSums, Codefights, CodeSignal Aracade Intro #14 AlternatingSums, Codefights, CodeSignal 코드파이트, 코드시그널 Q. You are given an array of positive integers - the weights of the people. Return an array of two integers, where the first element is the total weight of team 1, and the second element is the total weight of team 2 after the division is complete. 양의 정수 배열을 입력받고(사람들 몸무게), 두개의 정수를 반환하는데..홀수번째 배열의 합(첫번째팀), 짝수번째 사람들 무게의 합(두번째팀)..
Aracade Intro #13 ReverseParentheses, Codefights, CodeSignal, 코드파이트, 알고리즘, algorithm Aracade Intro #13 ReverseParentheses, Codefights, CodeSignal, 코드파이트, 알고리즘, algorithm 이거 진짜 재귀로 풀기 젼나 빡쎘슴.. It was hella hard to solve using recursive.. Q. You have a string s that consists of English letters, punctuation marks, whitespace characters, and brackets. It is guaranteed that the parentheses in s form a regular bracket sequence. Your task is to reverse the strings contained in each pai..