Free Lines Arrow
본문 바로가기
728x90

Algorithm/번외3

[Algorithm] version max 값 찾기 버전 정보가 있을때 맥스값을 찾아보자 어렵게 풀기 public void findMaxVersion() { String[] version = {"1.2.3", "2.2", "2.8", "2.7.1", "1.23.1"}; int minLength = 0; int maxIndex = 0; String maxVersion = version[0]; for (int i = 1; i < version.length; i++) { int maxLength = Math.max(version[i].length(), maxVersion.length()); String[] splitedMaxVersion = maxVersion.split("\\."); String[] splitedVersion = version[i].split.. 2023. 1. 23.
[Algorithm] 뿌요뿌요(퍼즐게임) 뿌요뿌요(퍼즐게임) 일단 이것을 구현한 것은 코딩테스트를 보다 보면 퍼즐문제가 나오는 경우가 있다.. 연습삼아 구현해 보았다. 참고로 처음 구현해봐서 리팩토링이 많이 필요하다. 문제 한칸에 하나씩 하나의 블록을 놓는다. 이미 블록이 있으면 그위에 둔다. 쌓다가 3개 이상의 블록이 연결되는 순간 삭제한다. 분석 일단 3개가 필요해 보인다. 쌓는 로직. 삭제하는 로직. 리프레쉬 하는 로직. 구현 package algorithm; import java.awt.*; import java.util.ArrayList; class CandidatePoint { public CandidatePoint(int x, int y) { this.x = x; this.y = y; } private int x; private i.. 2021. 10. 19.
[Algorithm] 벌집 만들기 문제 벌집 모양으로 순서대로 숫자를 채워 나간다. size 에 따라서 크기가 결정된다. 분석 한바퀴 돌았으면 돌았다는 것을 확인하기 위해 rotate 플래그 사용 한바퀴 돌면 한 면에 둘수 있는 size 를 줄여야 한다. 구현 package algorithm.prim; public class HoneyComb { private int [][]map; private int mapMaxX; private int mapMaxY; private int length; private boolean rotate = false; private int []dirX = {1, 2, 1, -1, -2, -1}; private int []dirY = {1, 0, -1, -1, 0, 1}; public void setLengt.. 2021. 10. 5.
728x90
반응형