๋ฌธ์
์ฝ๋ฉํ ์คํธ ์ฐ์ต - ์ ํ๋ฒํธ ๋ชฉ๋ก
์ ํ๋ฒํธ๋ถ์ ์ ํ ์ ํ๋ฒํธ ์ค, ํ ๋ฒํธ๊ฐ ๋ค๋ฅธ ๋ฒํธ์ ์ ๋์ด์ธ ๊ฒฝ์ฐ๊ฐ ์๋์ง ํ์ธํ๋ ค ํฉ๋๋ค. ์ ํ๋ฒํธ๊ฐ ๋ค์๊ณผ ๊ฐ์ ๊ฒฝ์ฐ, ๊ตฌ์กฐ๋ ์ ํ๋ฒํธ๋ ์์์ด์ ์ ํ๋ฒํธ์ ์ ๋์ฌ์ ๋๋ค. ๊ตฌ์กฐ
programmers.co.kr
์ฝ๋
#include <string> #include <vector> #include <algorithm> using namespace std; bool solution(vector<string> phone_book) { bool answer = true; sort(phone_book.begin(),phone_book.end()); for(int i=0; i<phone_book.size()-1; i++){ if(phone_book[i]==phone_book[i+1].substr(0,phone_book[i].length())) answer=false; } return answer; }
'Algorithm ๐ง๐ปโ๐ป > ํ๋ก๊ทธ๋๋จธ์ค(Programmers)' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[c++] ํ๋ก๊ทธ๋๋จธ์ค - ์ต๋๊ฐ๊ณผ ์ต์๊ฐ( Level 2) (0) | 2021.10.22 |
---|---|
[c++] ํ๋ก๊ทธ๋๋จธ์ค - ์ฒด์ก๋ณต( Level 1) (0) | 2021.10.22 |
[c++] ํ๋ก๊ทธ๋๋จธ์ค - ์ง์ง์ด ์ ๊ฑฐํ๊ธฐ( Level 2) (0) | 2021.10.22 |
[c++] ํ๋ก๊ทธ๋๋จธ์ค - ์์ฐ์ ๋ค์ง์ด ๋ฐฐ์ด๋ก ๋ง๋ค๊ธฐ( Level 1) (0) | 2021.10.22 |
[c++] ํ๋ก๊ทธ๋๋จธ์ค - ์ด์ค ์ฐ์ ์์ํ( Level 3) (0) | 2021.10.22 |
[c++] ํ๋ก๊ทธ๋๋จธ์ค - ์ด์ํ ๋ฌธ์ ๋ง๋ค๊ธฐ( Level 1) (0) | 2021.10.22 |
๋๊ธ