์• ์ •์ฝ”๋”ฉ ๐Ÿ’ป
347. Top K Frequent Elements

https://leetcode.com/problems/top-k-frequent-elements/ Top K Frequent Elements - LeetCode Can you solve this real interview question? Top K Frequent Elements - Given an integer array nums and an integer k, return the k most frequent elements. You may return the answer in any order. Example 1: Input: nums = [1,1,1,2,2,3], k = 2 Output: [1,2] leetcode.com Given an integer array nums and an integer..

49. Group Anagrams

https://leetcode.com/problems/group-anagrams/ Group Anagrams - LeetCode Can you solve this real interview question? Group Anagrams - Given an array of strings strs, group the anagrams together. You can return the answer in any order. An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase leetcode.com Given an array of strings strs, group the anagrams toget..

242. Valid Anagram

https://leetcode.com/problems/valid-anagram/ Valid Anagram - LeetCode Can you solve this real interview question? Valid Anagram - Given two strings s and t, return true if t is an anagram of s, and false otherwise. An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using leetcode.com Given two strings s and t, return true if t is an anagram ..

article thumbnail
[Java] ๋ฐฑ์ค€ 5585 : ๊ฑฐ์Šค๋ฆ„๋ˆ

๋ฌธ์ œ ํƒ€๋กœ๋Š” ์ž์ฃผ JOI์žกํ™”์ ์—์„œ ๋ฌผ๊ฑด์„ ์‚ฐ๋‹ค. JOI์žกํ™”์ ์—๋Š” ์ž”๋ˆ์œผ๋กœ 500์—”, 100์—”, 50์—”, 10์—”, 5์—”, 1์—”์ด ์ถฉ๋ถ„ํžˆ ์žˆ๊ณ , ์–ธ์ œ๋‚˜ ๊ฑฐ์Šค๋ฆ„๋ˆ ๊ฐœ์ˆ˜๊ฐ€ ๊ฐ€์žฅ ์ ๊ฒŒ ์ž”๋ˆ์„ ์ค€๋‹ค. ํƒ€๋กœ๊ฐ€ JOI์žกํ™”์ ์—์„œ ๋ฌผ๊ฑด์„ ์‚ฌ๊ณ  ์นด์šดํ„ฐ์—์„œ 1000์—” ์ง€ํ๋ฅผ ํ•œ ์žฅ ๋ƒˆ์„ ๋•Œ, ๋ฐ›์„ ์ž”๋ˆ์— ํฌํ•จ๋œ ์ž”๋ˆ์˜ ๊ฐœ์ˆ˜๋ฅผ ๊ตฌํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค. ์˜ˆ๋ฅผ ๋“ค์–ด ์ž…๋ ฅ๋œ ์˜ˆ1์˜ ๊ฒฝ์šฐ์—๋Š” ์•„๋ž˜ ๊ทธ๋ฆผ์—์„œ ์ฒ˜๋Ÿผ 4๊ฐœ๋ฅผ ์ถœ๋ ฅํ•ด์•ผ ํ•œ๋‹ค. ๋ฌธ์ œ ์š”๊ตฌ์กฐ๊ฑด 1. ์ž”๋ˆ 500,100,50,10,5,1์ด ์žˆ๋‹ค. 2. ๊ฑฐ์Šค๋ฆ„๋ˆ ๊ฐœ์ˆ˜๋ฅผ ๊ฐ€์žฅ ์ ๊ฒŒ ์ค€๋‹ค. 3. ์ž”๋ˆ ๊ฐœ์ˆ˜๋ฅผ ์ถœ๋ ฅํ•˜๋ผ. count๋Š” for๋ฌธ์„ ๋Œ๋ฉด์„œ ๋ชซ์„ ๊ตฌํ•  ๊ฒƒ์ธ๋ฐ 200์›์ด ๋‚จ์•˜๋‹ค๋ฉด ๋ชซ์ด 2๊ฐœ ๋  ํ…Œ๋‹ˆ ๋™์ „ 2๊ฐœ์™€ ๊ฐ™์€ ์˜๋ฏธ์ด๋‹ค. ๊ทธ๋‹ค์Œ ๋‚˜๋จธ์ง€ ๊ธˆ์•ก์„ ์ž”๋ˆ์— ๋‹ค์‹œ ๋Œ€์ž…ํ•˜์—ฌ ๊ณ„์‚ฐํ•˜..