본문 바로가기

Stacks and Queues4

[codility] StoneWall StoneWallCover "Manhattan skyline" using the minimum number of rectangles.Task Score100%Correctness100%Performance100% 아니.. painless라고 했잖아요 ㅠ짱구 굴리느라 너무 힘들었다.스택도 써보고 큐도 써보고 리스트도 써보고 콜렉션도 써보고 해쉬셋도 써보고 난리난리를 치다가혼자 그림그리고 순서도 써보고 글로 적어보고 난리난리를 치다가결국 누구누구한테 수학적으로 힌트를 받기는 했지만 결국 성공했다....자존심상해..☆ 아무튼~~ 설명을 해보자면, 힌트는 받았지만 코드를 받은게 아니라 그냥 수학적 접근법 정도였어서얘기를 듣고나니 가닥은 잡혔지만 정확히 로직을 어떻게 짜나갈지 고민이됐다.그래서 열심히 그림판으로 .. 2019. 12. 22.
[codility] Nesting NestingDetermine whether a given string of parentheses (single type) is properly nested.Task Score100%Correctness100%Performance100% Brackets랑 다른게 뭔데 ㅠ똑같이 풀어도 똑같이 100퍼 나오는거 뭔데ㅠ..그냥 if문 조건만 if(A){} if(B){}에서 if(A||B){}로만 바꿨다..ㅎ x// you can also use imports, for example:import java.util.*;​// you can write to stdout for debugging purposes, e.g.// System.out.println("this is a debug message");​clas.. 2019. 12. 20.
[codility] Fish FishN voracious fish are moving along a river. Calculate how many fish are alive.Task Score100%Correctness100%Performance100% 뭔가 귀여운데 잔인한 자연의 섭리같은 문제..A 배열에는 물고기의 크기,B 배열에는 물고기의 방향이 나타나있다. (0이면 올라가고, 1이면 내려가고)배열의 인덱스가 앞일수록 물고기는 더 위에 있다. 결국 나보다 앞 인덱스인 물고기가 내가잡아먹어서 없는상황에서 내가 위로(0) 올라가면 사는거고, 내가 다 잡아먹어서 제일 마지막 인덱스인데 내려가면 사는거다. 처음에 이상하게 혼자 복잡하게생각해서 스택 두개가지고 난장판을 피우다가 0%의..처참한 점수를 받고 정신차리고 하나의 스택으로 제.. 2019. 12. 12.
[codility] Brackets BracketsDetermine whether a given string of parentheses (multiple types) is properly nested.Task Score100%Correctness100%Performance100% 오랜만에 풀어보는 코딜리티문제~!요새 스택 문제가 풀어보고싶었는데 딱 좋은 문제를 만났다. // you can also use imports, for example:import java.util.*;​// you can write to stdout for debugging purposes, e.g.// System.out.println("this is a debug message");​class Solution { public int solution(String .. 2019. 12. 11.