본문 바로가기

leetcode

(151)
Aracade Intro #12 SortByHeight CodeFights, CodeSignal arcade #12 SortByHeight Rearrange the people by their heights in a non-descending order without moving the trees. ( -1 would be tree ) 입력받은 사람들의 키와 나무(-1) 값 배열에서, 나무값의 위치는 건드리지 않고 사람들의 키를 오름차순 정렬하라 e.g. a = [-1, 150, 190, 170, -1, -1, 160, 180] sortByHeight(a) = [-1, 150, 160, 170, -1, -1, 180, 190] 함수를 통과하고 정렬된 값 //Process//1. Input height vector//2. Iterate from 1 to the..
Aracade Intro #11 IsLucky CodeFights, CodeSignal Arcade #11 IsLucky If the sum of half of digits is equal to the sum of second half, it's true, or false. 자릿수가 짝수개인 정수를 입력받고,앞자리 절반의 자릿수 합과 뒷자리 절반 자릿수의 합이 같으면 true, 아니면 false e.g. 123321 -> true 1 + 2 + 3 = 3 + 2 + 1 1230 -> true 1 + 2 = 3 + 0 124582 -> false 1 + 2 + 4 != 5 + 8 + 2 124214 -> true 123456 -> false //Process//1. Input int//2. Get length of input int (alway eve..
Aracade Intro #10 CommonCharacterCount CodeFights arcade intro #10 Given two strings, get the total number of common characters between them. 주어진 2개의 String에서, 똑같은 Character의 총 개수를 구하라. //Process//1. Input two strings//2. Iterate first string from begin to the end// 2.1. If the number is not existed in the charArray1, then add and count// 2.2. If existed, just count//3. Iterate second string from begin to the end// 3.1. If the number..
Windows 10 show desktop icon(My computer, Document...) 윈도우 10 데스크톱 아이콘 보기 (내컴퓨터, 내문서 등) How to show Desktop icons visible 바탕화면 아이콘 보이게 하기 1. Right click on the Desktop 2. Click Personalization 3. Click Theme 4. Choose the icons you want to make visible 5. Save and exit 1. 바탕화면 오른쪽 클릭 2. 개인 설정 클릭 3. 왼쪽에서 테마에 클릭 4. 보이게 하고 싶은 바탕화면 아이콘 설정 5. 저장 종료 그외 알고리듬 문제 2018/09/26 - [Algorithm/Code Signal (Code Fights)] - Aracade Intro #9 AllLongestStrings2018/09/24 - [Algorithm/Code Signal (Code ..
C++ Math - floor/ceil/round (내림/올림/반올림) C++ Math - floor/ceil/round (내림/올림/반올림) 자바 Math class 관련 포스팅을 하면서 C++도 같이 한다.C++ 은 MSDN에 자세하게 잘 나와있어서 거의 고대로 가져오고 반올림만 추가했다. math.h 헤더 추가해주고, floor -> 내림 (floor)ceil -> 올림 (ceiling)round -> 반올림 (round) The thing different with Java Math class is that the math in C++ about floor, round, and ceil is not only for double data type, but also include float. 자바의 Math 클래스와 다른 점은, 자바에서는 abs (절대값) 빼고는 전부 ..
Java 자바 Math class - round/ceil/floor/abs (반올림/올림/내림/절대값) 자바에서 쓰는 Math 클래스 (Static class - 정적 클래스) 최근에 Matlab 에서 Java로 포팅을 할 일이 있어서 Math 클래스를 자주 쓰는데 뭐라도 하나 블로그에 올려놓고 싶어서 쓰게 되었다. 3 methods below are basically ceil/floor/round the double data type, and return the integer.0 shape double data. 아래 3가지는 기본적으로 실수 소수점을 내림/올림/반올림 해서 정수.0 형태의 double을 반환한다. floor -> 내림 (바닥으로 floor)ceil -> 올림 (천장으로 ceiling)round -> 반올림 (반올림 round) 절대값은 long, float, int, double 전부 ..
Aracade Intro #9 AllLongestStrings AllLongestStringsGiven an array of strings, returns another array containing all of it's longest strings입력받은 문자 배열에서, 가장 긴 문자들만 따로 뽑은 배열을 리턴해라 //Process//1. Input strings array//2. Iterate from begin to the end// 2.1. Check string's length// 2.2. If it's longer than longest string, -> make new output longest string array// 2.3. If it's same length, -> add//3. Return outputArray //처리과정//1. 문자배열을 ..
Aracade Intro #8 MatrixElementsSum Each cell in the matrix contains an integer that represents the price of them. Some rooms are free(0), because they are haunted. They are not suitable to live in.Calculate the total price of all the rooms that are suitable to live in. 입력받은 2차원 배열(월세 가격)에서 0 인 위치는 귀신이 있는 집이다.가격이 0인 위치와 0의 바로 아랫줄(같은 열) 은 어디든 살기 싫다. 살 수 있는 적합한 방의 배열위치에 있는 모든 가격(정수)의 합을 구하라. e.g. matrix = [[ 1, 3, 4, 0 ], [ 3, 0, 6,..