# A Sign of Inequality

* **입력**

여러 개의 char 타입의 데이터를 입력 받을 때, Scanner로 바로 입력받을 순 없다.

next()를 적절히 사용하여 String을 char로 변환시켜줘야한다.

next() : 공백문자 단위로 String을 입력받는다.

```java
//Hello World 입력시
String s = sc.next();
//s 출력해보면
s = Hello;
```

한 글자씩 입력 받을 때 : sc.next()로 받는 String의 첫번째 문자만 가져오면 된다!\
\=> sc.next().toCharArray()\[0];//sc.next()로 받는 String을 char형 배열로 바꾸고 그 배열에서 0번째 값을 가져온다!

```java
for(int i=0;i<n;i++) {
		a[i] = sc.next().toCharArray()[0];
}
```

* **트러블 슈팅**

에러에 답이 다 있다!

![에러 발생 상황](/files/-MaY9PmjeEedyp6wezsP)

ans에 분명 String s를 추가해서 0일리가 없는데 길이가 0이고 -1이 인덱스 범위초과라고 나온다! => ans에 s가 제대로 추가되지 않았나보다!

조건 판단을 하는 ok 함수부터, 재귀함수 내에서 정답인 경우를 체크하는 부분 모두 리뷰했는데 틀린 것이 없었다.

문제는 다음 경우를 호출하는 부분에서 나왔다! 현재의 위치를 index라고 하고, 현재위치에서 넣을 수를 i라고 한다면, 다음 함수를 호출할 때는 go(index+1, num+Integer.toString(i)); 이렇게 현재 넣을 수를 문자열로 변환하여 넣어줘야하는데 나는 index를 넣어줘서 틀렸다.

왜냐하면 현재 index=2, 현재 넣을 수 i=9라고 하면 7 < 8 < 9 => 7 < 8 < 2 가 되버리고, 조건에 만족하지 않아 ans에는 문자열들이 제대로 추가되지 않게된다! 그래서 디버깅 결과 ans는 0이 되었고, 길이가 0인 ans에 -1번째에 접근하려하니 위와 같은 index 초과 에러가 나게 되었다!

**느낀 점**

다음부터는 답안을 보지 않고 스스로 디버깅해서 정답을 도출해보도록하자!


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://heunnajo.gitbook.io/algorithms-problem-solving-skills/brute-force/a-sign-of-inequality.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
