본문 바로가기

Algorithm/Code Fights (Code Signal)

(68)
Aracade Intro #4 AdjacentElementsProduct Given an array of integers, find the pair of adjacent elements that has the largest product and return that product. 입력받은 정수배열에서 인접한 두 값의 합이 최대인 값을 반환한다. //Process//1. Input integer array//2. Iterate from begin to the end - 1// 2.1. Get the value of i and i+1 integer// 2.2. Check if it's largest number or not, if so -> change//3. Return largestNumber //처리과정//1. 정수 배열 입력받는다.//2. 시작부터 끝-1 까지 반복한다...
Aracade Intro #3 CheckPalindrome Check if input string is palindrome or not 입력받는 문자가 회문(수박이박수) 인지 확인한다 //Process//1. Input string for checking//2. Iterate from the front char and the rear char are the same && till they meet// 2.1. Update front and rear char//3. Get the answer and output it //처리과정//1. 체크할 문자 입력받는다.//2. 앞에서, 뒤에서 문자 읽어서 같아야 하고, 중간에서 만나기 전까지 반복한다.// 2.1. 체크할 앞 뒤 문자 갱신한다.//3. 끝까지 왔으면 답은 true 로 출력한다. bool checkPalind..
Aracade Intro #2 CenturyFromYear Calculate century from year연도를 입력받고 세기를 계산한다 // Process//1. Input year//2. Divide year by 100//3. If it doesn't have remainder -> quotient is century// 3.1. If it has remainder -> quotient + 1 is century//4. Output century // 처리과정//1. 연도를 입력받는다.//2. 연도를 100으로 나눠본다.//3. 나누어 떨어지면 몫(100단위)이 세기// 3.1. 나머지가 있으면 몫 + 1 이 세기//4. 세기를 출력한다. int centuryFromYear(int year) { int quotient = year / 100; int re..
Aracade Intro #1 Add 코드파이트 때 부터 아케이드 인트로 부분 C++로 푼 내용What I solved in CodeFights(CodeSignal) using C++ #1 int add(int param1, int param2) { return param1 + param2;}