Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Com #1

Open
wants to merge 40 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
a17dbb2
test commit
yangyanghyunjung Oct 12, 2023
78c1188
과연 성공??
yangyanghyunjung Oct 12, 2023
afdb9b7
커밋커밋
Oct 13, 2023
6d33639
Revert "커밋커밋"
Oct 13, 2023
4c87a52
com 커밋 테스트
Oct 13, 2023
837201d
머지 충돌 해결
Oct 13, 2023
4abe54b
onbarding_problem1 완성
Oct 13, 2023
a1926eb
기능목록 작성
Oct 16, 2023
fd19d69
StringValidation 기능 commit
Oct 16, 2023
a40e9ed
FindAndRemoveDuplicate 기능 구현
Oct 16, 2023
4ae9fc5
FindAndRemoveDuplicate 중복값 삭제 기능
Oct 16, 2023
0491c35
코드리뷰 2jun0's 중복값 제거 기능
Oct 16, 2023
39fd647
Test code 추가
Oct 16, 2023
c85be62
Problem2 Main함수
Oct 16, 2023
0e1278b
머지 충돌 해결
Oct 13, 2023
8c8fae3
충돌
Oct 16, 2023
662d614
FindAndRemoveDuplicate 충돌 해결
Oct 16, 2023
7c2e754
FindAndRemoveDuplicate 충돌 해결2
Oct 16, 2023
cffe4b9
Test코드 충돌 해결2
Oct 16, 2023
e3d672d
yangyanghunjung branch test
Oct 17, 2023
672b92c
yangyanghunjung branch test2
Oct 17, 2023
4ef0008
커밋커밋
Oct 13, 2023
8d804b2
과연 성공??
yangyanghyunjung Oct 12, 2023
dc26ea0
커밋커밋
Oct 13, 2023
b980c55
Revert "커밋커밋"
Oct 13, 2023
64ab12d
com 커밋 테스트
Oct 13, 2023
59d0351
onbarding_problem1 완성
Oct 13, 2023
af99c0f
기능목록 작성
Oct 16, 2023
0b97538
StringValidation 기능 commit
Oct 16, 2023
c3f12c7
FindAndRemoveDuplicate 기능 구현
Oct 16, 2023
6f83d18
FindAndRemoveDuplicate 중복값 삭제 기능
Oct 16, 2023
65c41f9
코드리뷰 2jun0's 중복값 제거 기능
Oct 16, 2023
4bac3b8
Test code 추가
Oct 16, 2023
a53c4a3
Problem2 Main함수
Oct 16, 2023
047a7b8
충돌
Oct 16, 2023
eca9aab
FindAndRemoveDuplicate 충돌 해결
Oct 16, 2023
061c8cb
FindAndRemoveDuplicate 충돌 해결2
Oct 16, 2023
a808f29
Test코드 충돌 해결2
Oct 16, 2023
668c6bd
Merge branch 'com' of https://github.com/yangyanghyunjung/java-onboar…
Oct 17, 2023
ae35432
커밋커밋;;
Oct 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Git 연결 확인 test2
- - -
- hellogut
- hi
20 changes: 20 additions & 0 deletions src/main/java/Problem2/FindAndRemoveDuplicate.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package Problem2;
import java.util.ArrayList;
import java.util.Arrays;

public class FindAndRemoveDuplicate {
public String FindAndRemve (String cryptogram)
{
String[] cryptogramArray = cryptogram.split("");
ArrayList<String> cryptogramList = new ArrayList<String>(Arrays.asList(cryptogramArray));
for (int i = 0; i <cryptogramList.size() - 1; i++) {
if (cryptogramList.get(i).equals(cryptogramList.get(i + 1))) {
cryptogramList.remove(i);
cryptogramList.remove(i);
i -= 2;
}
}
String str = String.join("",cryptogramList);
return str;
}
}
18 changes: 18 additions & 0 deletions src/main/java/Problem2/StringValidation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package Problem2;

public class StringValidation {
public boolean Validate (String cryptogram) {
// 문자열 길이 오류
if (cryptogram.length() < 1 || cryptogram.length() > 1000) {
return false;
}
// 대문자 포함될 경우
char[] charArray = cryptogram.toCharArray();
for (int i = 0; i < charArray.length; i++) {
if (Character.isUpperCase(charArray[i])) {
return false;
}
}
return true;
}
}
35 changes: 35 additions & 0 deletions src/main/java/Problem2/eJun0SSockSSock.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package Problem2;

import java.util.Stack;

public class eJun0SSockSSock {
// 2jun0's Code
// 1. Stack 생성
// 2. for문 순회
// 3. push || pop

public String ConvertStackToString(Stack<Character> stack) {
StringBuilder sb = new StringBuilder();
// 후입선출 고려 0번째 index에 add가 아닌 insert 해줌.
while (!stack.isEmpty()) { //모두 pop() 되면 종료
// pop()은 제거하면서 sb에 insert도 가능한가봄
sb.insert(0,stack.pop());
}
return sb.toString();
}
public String RemoveDuplicate(String cryptogram) {
Stack<Character> stack = new Stack<Character>();

for (char c: cryptogram.toCharArray()) {
// 나는 문자열 비교시 equals ( 참조형 비교 위해) 썼는데 char은 기본형이라 == 시용 가능
if (stack.size() > 0 && stack.peek().equals(c)) {
stack.pop();
} else {
stack.push(c);
}
}
return ConvertStackToString(stack);
}


}
16 changes: 16 additions & 0 deletions src/main/java/Problem2/functionList.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# 🚀 problem2 기능 목록
- - -
### 1. StringValidation
```java
System.out.println("예외");
```
- 글자수가 **1**이하 **1000** 이상일 경우
- **대문자**가 들어올 경우
- 빈문자열 값: ```return 빈문자열```
- - -
### 2. FindAndRemoveDuplicate
- **LinkedList**로 첫 문자부터 순회
- 반복문자 나올 시 next node **포인터 변경** (삭제)
- 반복이 없다면 다음 node로 이동
- ```return 최종 문자열```

12 changes: 12 additions & 0 deletions src/main/java/hi/Compare.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package hi;

public class Compare {
public int CompareScore(Integer largePobiScore ,Integer largeCrongScore) {
if (largePobiScore < largeCrongScore) {
return 2;
} else if (largePobiScore > largeCrongScore) {
return 1;
}
return 0;
}
}
28 changes: 28 additions & 0 deletions src/main/java/hi/Page.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package hi;

import java.util.List;
import hi.Score;

public class Page {
private static final int MIN = 3;
private static final int MAX =398;

public int PageValidation (List<Integer> pobi, List<Integer> crong) {
int pobiLeft = pobi.get(0);
int pobiRight = pobi.get(1);
int crongLeft = crong.get(0);
int crongRight = crong.get(1);

if (pobiRight - pobiLeft != 1 || crongRight - crongLeft != 1) {
return -1;
}
if (pobiLeft < MIN || pobiLeft > MAX || crongLeft < MIN || crongLeft > MAX
|| pobiRight < MIN || pobiRight > MAX || crongRight < MIN || crongRight > MAX) {
return -1;
}
Score score = new Score();
int win = score.LargeScore(pobiLeft, pobiRight, crongLeft, crongRight);

return win;
}
}
40 changes: 40 additions & 0 deletions src/main/java/hi/Score.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package hi;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class Score {
public Integer LargeScore(Integer pobiLeft, Integer pobiRight, Integer crongLeft, Integer crongRight) {

int largePobiScoreLeft = Calculate(pobiLeft);
int largePobiScoreRight = Calculate(pobiRight);
int largeCrongScoreLeft = Calculate(crongLeft);
int largeCrongScoreRight = Calculate(crongRight);

int largePobiScore = largePobiScoreLeft < largePobiScoreRight ? largePobiScoreRight : largePobiScoreLeft;
int largeCrongScore = largeCrongScoreLeft < largeCrongScoreRight ? largeCrongScoreRight : largeCrongScoreLeft;

Compare compare = new Compare();
int win = compare.CompareScore(largePobiScore, largeCrongScore);

return win;
}
public int Calculate (int score) {
LinkedList<Integer> scoreLists = new LinkedList<>();
while (score > 0) {
scoreLists.push(score % 10);
score /= 10;
}
int add = 0;
int mul = 1;
for (int i = 0; i < scoreLists.size(); i++) {
add += scoreLists.get(i);
mul *= scoreLists.get(i);
}

return add < mul ? mul : add;
}
}


7 changes: 5 additions & 2 deletions src/main/java/onboarding/Problem1.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package onboarding;

import java.util.List;
import hi.Page;

class Problem1 {
public static int solution(List<Integer> pobi, List<Integer> crong) {
int answer = Integer.MAX_VALUE;
return answer;
Page page = new Page();
int score = page.PageValidation(pobi, crong);
System.out.println(score);
return score;
}
}
17 changes: 15 additions & 2 deletions src/main/java/onboarding/Problem2.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
package onboarding;
import Problem2.StringValidation;
import Problem2.FindAndRemoveDuplicate;
import Problem2.eJun0SSockSSock;

public class Problem2 {
public static String solution(String cryptogram) {
String answer = "answer";
return answer;
// 문자열 validation check return boolean
StringValidation stringValidation = new StringValidation();
if (!stringValidation.Validate(cryptogram)) {
return "";
}
// validation check 값이 true면 중복 삭제
// FindAndRemoveDuplicate FRD = new FindAndRemoveDuplicate();
// String result = FRD.FindAndRemve(cryptogram);
//2jun0's
eJun0SSockSSock ejun0 = new eJun0SSockSSock();
String result = ejun0.RemoveDuplicate(cryptogram);
return result;
}
}
Loading