![[Java] 메모장 - COS Pro 1급 모의고사 프로그래머스](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FcAKp9j%2FbtsatWtnEOB%2F00mjXkoUDYsIulFCGbvuK1%2Fimg.png)
[Java] 메모장 - COS Pro 1급 모의고사 프로그래머스P.S./프로그래머스2023. 4. 17. 08:38
Table of Contents
728x90
728x90
https://school.programmers.co.kr/learn/courses/11132/lessons/71157
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
풀이
단순한 문제
words 배열의 반복문을 통해 검증하면 끝... 설명이 딱히 필요없음
public int solution(int K, String[] words) {
if(words.length==1) return 1;
int answer = 1;
int size = 0;
for(int i=0; i<words.length; i++){
if(size + words[i].length() > K){
answer++;
size=0;
}
size += words[i].length()+1;
}
return answer;
}

728x90
300x250
@mag1c :: 꾸준히 재밌게
2023.04 ~ 백엔드 개발자의 기록
포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!