Shortest Word
Last updated
Was this helpful?
Last updated
Was this helpful?
Simple, given a string of words, return the length of the shortest word(s).
String will never be empty and you do not need to account for different data types.
๋ฌธ์ฅ์์ ๊ฐ์ฅ ์งง์ ๋จ์ด๋ฅผ ์ฐพ์๋ด์ด ๋จ์ด์ ์๋ฅผ return ํ๋ค.
๋จ์ด๋ฅผ Array ๋ฉ์๋์ธ split๋ฅผ ์ด์ฉํด ๋ฐฐ์ด์ ์์๋ก ๋ด๋๋ค.
for๋ฌธ์ ์ด์ฉํด ์์์ ๊ฐ์ฅ ์งง์ ๋จ์ด์ length๋ฅผ ๋ณ์์ ๋ด๋๋ค.
length๋ฅผ ๋ด์ ๋ณ์๋ฅผ return ํ๋ค.
ํต๊ณผ
๋๊ฐ์ solution ๋ค Math,min์ ์ฌ์ฉํ์๋ค.
์ฐจ์ด๋ apply๋ฅผ ์ด์ฉํด ๋ฐฐ์ด์ ์ด๊ฑฐ ํ๊ฑฐ๋ spread ์ฐ์ฐ์๋ฅผ ์ฌ์ฉํ์๋ค.
, , , , , (plus 42 more warriors)