회원가입
로그인
Toggle navigation
문제
문제
전체 문제
문제 출처
단계별로 풀어보기
알고리즘 분류
추가된 문제
문제 순위
문제
푼 사람이 한 명인 문제
아무도 못 푼 문제
최근 제출된 문제
최근 풀린 문제
랜덤
출처
ICPC
Olympiad
한국정보올림피아드
한국정보올림피아드시․도지역본선
전국 대학생 프로그래밍 대회 동아리 연합
대학교 대회
카카오 코드 페스티벌
Coder's High
ICPC
Regionals
World Finals
Korea Regional
Africa and the Middle East Regionals
Europe Regionals
Latin America Regionals
North America Regionals
South Pacific Regionals
문제집
대회
1
채점 현황
랭킹
게시판
그룹
더 보기
재채점 기록
블로그
강의
실험실
도움말
BOJ Stack
BOJ Book
전체
공지
자유
질문
오타/오역/요청
게시판 공지
홍보
업데이트
solved.ac
글쓰기
질문 도움말
자주묻는 질문
1874[자바스크립트] 반례 다 써놨습니다. 문제가 뭘까요??
1874번 - 스택 수열
jcdoom
3년 전
0
게시판 다 읽은거 같은데,,,, 도저히 못찾겠녜요......
형님들 한번만 도와주세요!!!!!!!!!
// const input = [8, 4,3,6,8,7,5,2,1, "\n"]; // const input = [5, 1,2,5,3,4, "\n"]; // const input = ["MyTest", 3,1,2, "\n"]; // const input = ["MyTest", 3,1,2,4, "\n"]; // const input = ["MyTest", 1,2, "\n"]; // const input = ["MyTest", 1,4,3,5,2,6, "\n"]; // const input = ["MyTest", 1,3,4,2, "\n"]; // const input = ["MyTest", 4,3,2,1, "\n"]; // const input = ["MyTest", 1,2,3,4, "\n"]; // const input = ["MyTest", 4,2,3,1, "\n"]; // const input = ["MyTest", 1, "\n"]; // +[1] , 2345, '' // -[] , 2345, 1 // +[2] , 345, 1 // -[] , 345, 12 // +[3] , 45, 12 // +[3,4] , 5, 12 // +[3,4,5] , '', 12 // -[3,4], '', 125 // +............ const input = require('fs').readFileSync('/dev/stdin').toString().split('\n'); input.pop(); // 마지막 엔터 제거. input.shift(); // 처음의 카운트 제거. const arr = []; let inputIndex = 0; let num = 0; let str = ""; while(true) { if(input[inputIndex] !== arr[arr.length-1]) { num++; let pushValue = num; arr.push( pushValue ); str += `\n+`; } else if(input[inputIndex] === arr[arr.length-1]) { inputIndex++; arr.pop(); str += `\n-`; } if(num > input.length) { console.log("NO"); break; } if(input.length === inputIndex) { let log = str.slice(1); console.log(log); break; } }
댓글을 작성하려면
로그인
해야 합니다.
jcdoom 3년 전
게시판 다 읽은거 같은데,,,, 도저히 못찾겠녜요......
형님들 한번만 도와주세요!!!!!!!!!