Showing posts from 2018

greedy algorithm

# task-scheduler ( medium ) 매번 최대 count를 가진 character의 count를 줄여가면서 값을 찾음 ### 좋은 예제 - AAAABBCCDD inteval = 1 ```java public class Solution { public int leastInterval(char[] tasks, int n) { HashMap map = new HashMap(); Comparator comparator = new Comparator() { @Override public int compare(Number o1, Number o2) { return (o2.c - o1.c); } }; PriorityQueue numbers = new PriorityQueue(100, comparator); for(int i=0; i0){ count =0; ArrayList list = new ArrayList(); for(int i=0; i<=n; i++){ Number number = numbers.poll(); if(number == null){ break; } number.c--; count++; if(number.c ==0){ }else{ list.add(number); } } …

typescript basic-types

오랫만에 풀어본 문제 serialized and desirialize dfs 로 길을 갔었고 가는 곳 마다 흔적을 남겼고 다시 그 흔적을 따라 deserialized를 하면 풀리는 문제

async sync

8개월간 클라이밍으로 인한 신체 변화


지금부터 8개월전 클라이밍을 시작했고 지금 와서 인증샷을 찍었다

몸무게 78kg -> 76kg  -2kg
근육    30.1kg -> 31kg +1kg
체지방 24.7     -> 21.1  -3.3kg
체지방률 31.5% -> 27.7%

종합 점수 : 64점 -> 70점

엄청난 변화인것 같다.

클라이밍을 1년정도는 더 할 생각이 있는데
그때는 75점은 넘지 않을까 기대되네.

regular expression 사용 예제

오랫만에 패턴 매칭해서 결과값 구하는것 찾음.
regular expression은 내가 짠거는 쉬운데 남이 짠거는 잘 안읽힘. ㅠ

Pattern p = Pattern.compile("(([a-zA-Z][0-9][0-9]?)\\s*[\\/]\\s*.{3}\\s*[\\/]\\s*)");Matcher m = p.matcher(line); while(m.find())
T10 / name / AB12345

line encoding

I solved this problem with for 

somebody solved this one with reguar expression

Given a string, return its encoding defined as follows:
First, the string is divided into the least possible number of disjoint substrings consisting of identical charactersfor example, "aabbbc" is divided into ["aa", "bbb", "c"]Next, each substring with length greater than one is replaced with a concatenation of its length and the repeating characterfor example, substring"bbb" is replaced by "3b"Finally, all the new strings are concatenated together in the same order and a new string is returned.Example For s = "aabbbc", the output should be
lineEncoding(s) = "2a3bc". Input/Output [execution time limit] 3 seconds (java) [input] string s String consisting of lowercase English letters. Guaranteed constraints:
4 ≤ s.length ≤ 15. [output] string Encoded version of s. [Java] Syntax Tips // Prints help message to the console// Returns a string/…

codefights darkwilderness

My answer is O(n) and just use Math.abs 
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) = true. For bishop = "h1" and pawn = "h3", the output should be
bishopAndPawn(bishop, pawn) = false. Input/Output [execution time limit] 3 seconds (java) [input] string bishop Coordinates of the white bishop in the chess notation. [input] string pawn Coordinates of the black pawn in the same notation. [output] boolean true if the bishop can capture the pawn, false otherwise. [Java] Syntax Tips // Prints help message to the console// Returns a string// // Globals declared here will cause a compilation error,// declare variables inside th…