์• ์ •์ฝ”๋”ฉ ๐Ÿ’ป
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..

1. Two Sum

https://leetcode.com/problems/two-sum/submissions/ LeetCode - The World's Leading Online Programming Learning Platform Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. Yo..

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 ..

217. Contains Duplicate

https://neetcode.io/roadmap NeetCode.io neetcode.io Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct. class Solution(object): def containsDuplicate(self, nums): setCollection = set() for num in nums: if num in setCollection: return True setCollection.add(num) return False not(len(nums)==len(set(nums)))

article thumbnail
Java POI .addMergedRegion
๊ธฐํƒ€ 2023. 7. 27. 13:35

๋ณ‘ํ•ฉํ•˜๋Š” ๋ฐฉ๋ฒ• ๊ธฐ๋ก CellRangeAddress region1 = new CellRangeAddress(0,0,1,2); sheet.addMergedRegion(region1); CellRangeAddress region2 = new CellRangeAddress(0,0,3,4); sheet.addMergedRegion(region2); CellRangeAddress region3 = new CellRangeAddress(0,0,5,6); sheet.addMergedRegion(region3); CellRangeAddress region4 = new CellRangeAddress(0,1,0,0); sheet.addMergedRegion(region4); Row row = sheet.createRow(0..

article thumbnail
Gson ์€ ์™œ ๋ฉ‹๋Œ€๋กœ null ๊ฐ’์„ ๊ฐ€์ง„ ํ•„๋“œ๋ฅผ ์ œ์™ธํ•˜๋‚˜?

json ์œผ๋กœ ๊ฐ’์„ ๋ฐ›์œผ๋ฉด ํ‚ค์™€ ๊ฐ’ ์„ ๋งคํ•‘ํ•ด์„œ ์ด๋ฉ”์ผ์„ ์ „์†กํ•˜๋Š” ๊ธฐ๋Šฅ์„ ๊ฐœ๋ฐœํ•˜๊ณ  ์žˆ์—ˆ๋Š”๋ฐ ํ‚ค๋ฅผ ๊ณ„์† ๋ชป์ฐพ๋Š”๊ฒŒ ์ด์ƒํ•ด์„œ ํ™•์ธํ•ด๋ณด๋‹ˆ null ๊ฐ’์„ ๊ฐ€์ง„ ํ•„๋“œ๋Š” ์ œ์™ธํ•˜๊ณ  ์ง๋ ฌํ™”๋ฅผ ํ•˜๊ณ  ์žˆ์—ˆ๋‹ค. https://github.com/google/gson/blob/main/UserGuide.md#null-object-support ๊ธฐ๋ณธ์ ์œผ๋กœ Gson ์€ null ๊ฐ’์„ ๊ฐ€์ง„ ํ•„๋“œ๋ฅผ ์ œ์™ธํ•˜๊ณ  ์ง๋ ฌํ™” ํ•˜๊ณ  ์žˆ์–ด์„œ,, serializeNulls() ๋ฅผ ํ˜ธ์ถœํ•˜์—ฌ null ๊ฐ’์„ ํฌํ•จํ•˜๋Š” Gson ์ธ์Šคํ„ด์Šค๋ฅผ ์ƒ์„ฑํ•ด์•ผ ํ•œ๋‹ค. Gson gson = new GsonBuilder().serializeNulls().create(); String json = gson.toJson(exampleObject); ์™œ ๊ธฐ๋ณธ๊ฐ’์ด null ๊ฐ’์„ ์ œ..

article thumbnail
๊ฐ‘์ž๊ธฐ ์œ ๋‹ˆ์ฝ”๋“œ
๊ธฐํƒ€ 2023. 7. 2. 13:19

ํšŒ์‚ฌ์—์„œ ๋ฐฅ์„ ๋จน๋Š”๋ฐ ์กฐ์—˜ ์˜จ ์†Œํ”„ํŠธ์›จ์–ด ์–˜๊ธฐ๊ฐ€ ๋‚˜์™€์„œ ๋‹ค ์ฝ์ง€ ๋ชปํ•œ ์ด ์ฑ…์„ ๋‹ค์‹œ ํ•œ๋ฒˆ ํŽผ์ณ ๋ณด์•˜๋‹ค ํ…Œ์ŠคํŠธ์— ๋Œ€ํ•œ ๊ธ€์„ ์ฝ์–ด๋ณด๊ณ  ์žˆ์—ˆ๋Š”๋ฐ ๋ฐ”๋กœ ๋‹ค์Œ์žฅ์— ์œ ๋‹ˆ์ฝ”๋“œ์™€ ๋ฌธ์ž ์ง‘ํ•ฉ์— ๋Œ€ํ•œ ์ด์•ผ๊ธฐ๊ฐ€ ๋‚˜์™€์„œ ์ฒ˜์Œ ๋ณด๋Š” ๊ฒƒ ๋งˆ๋ƒฅ ํฅ๋ฏธ๋กญ๊ฒŒ ์ฝ์—ˆ๋‹ค. ์ €์ž๋Š” ์œ ๋‹ˆ์ฝ”๋“œ๋ฅผ ๋ชจ๋ฅธ๋‹ค๋ฉด ๋งน์„ธ์ฝ” ์ž ์ˆ˜ํ•จ์—์„œ 6๊ฐœ์›” ๋™์•ˆ ์–‘ํŒŒ ๊ป์งˆ์„ ๊นŒ๋Š” ๋ฒŒ์น™์„ ์ค€๋‹ค๊ณ  ํ•ด์„œ ์—ด์‹ฌํžˆ ์ฝ์—ˆ๋‹ค... ์ „์†ก๋˜๋Š” ์ธ์ฝ”๋”ฉ ๋ฐฉ์‹์„ ์ง€์ •ํ•  ์ˆ˜ ์žˆ๋Š”๋ฐ ์ง€๊ธˆ์€ Unicode๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์ง€๋งŒ ์ด์ „์—๋Š” ASCII ์™€ ๊ฐ™์€ ์ธ์ฝ”๋”ฉ ๋ฐฉ์‹์„ ์‚ฌ์šฉํ–ˆ๋‹ค. ํ•˜์ง€๋งŒ ASCII๋Š” 7๋น„ํŠธ๋กœ ๊ตฌ์„ฑ๋˜์–ด ์žˆ์–ด์„œ 0~127๊นŒ์ง€์˜ ์ˆซ์ž๋ฅผ ์ด์šฉํ•ด ์˜๋ฌธ ์•ŒํŒŒ๋ฒณ, ์ˆซ์ž, ํŠน์ˆ˜ ๋ฌธ์ž ๋“ฑ์„ ํ‘œํ˜„ํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค. (๋งจ ์™ผ์ชฝ 1๋น„ํŠธ๋Š” ํ†ต์‹  ์žฅ๋น„์—์„œ ์‚ฌ์šฉ๋˜๋Š” ์ œ์–ด ๋น„ํŠธ๋ฅผ ์œ„ํ•ด ์˜ˆ์•ฝ๋œ ๊ณต๊ฐ„์ด์—ˆ๊ณ  ์‹ค์ œ๋กœ๋Š” 7๋น„ํŠธ..

article thumbnail
Reflections of July
ํšŒ๊ณ  2023. 7. 1. 15:37

1์›” 1์ผ์— ์†Œ๋ž˜์‚ฐ ๊ฐ€์„œ ์ง€ํ‚ค์ง€ ๋ชปํ•  ์—ฌ๋Ÿฌ ๋ชฉํ‘œ๋“ค์„ ๋‹ค์งํ–ˆ๋˜๊ฒŒ ์ตœ๊ทผ์ผ ๊ฐ™์€๋ฐ ๋ฒŒ์จ 3๋ถ„๊ธฐ๋‹ค. ํšŒ๊ณ  ์“ฐ๋Š” ์ผ์€ ์ •๋ง ๊ท€์ฐฎ์ง€๋งŒ ๋ญ˜ํ–ˆ๋Š”์ง€ ํ™•์ธํ•˜๊ธฐ ์ข‹๋‹ค. ๊ทธ๋ฆฌ๊ณ  ๋‹ค์Œ๋‹ฌ์— ์–ด๋–ค๊ฑธ ํ• ์ง€๋„ ์ƒ๊ฐํ•  ์ˆ˜ ์žˆ๋‹ค. ํ‰์†Œ์—๋Š” ์ƒ๊ฐ์„ ํ•ด๋„ ๊ธˆ๋ฐฉ ์žŠ๊ธฐ ๋•Œ๋ฌธ์—... ๋‹ค์Œ ๋‹ฌ์—๋Š” ์–ด๋–ค ๊ฒŒ์‹œ๋ฌผ์„ ์ฝ์—ˆ๋Š”์ง€, ์–ด๋–ค ์ƒ๊ฐ์„ ํ–ˆ๋Š”์ง€๋„ ์จ์•ผ๊ฒ ๋‹ค. 7์›”์— ๋‚˜๋Š” ๋ญ˜ ํ–ˆ์„๊นŒ? ํŒ€์žฅ๋‹˜๊ณผ์˜ ์ฝ”๋“œ ๋ฆฌ๋ทฐ ์ƒˆ๋กœ์šด ํ”„๋กœ์ ํŠธ๋ฅผ ์‹œ์ž‘ํ–ˆ๋Š”๋ฐ ๋ชจ๋“  ์ •๋ณด๋ฅผ ๋งŒ๋“ค์–ด์ฃผ๋ฉด ํ•ด๋‹น ์ •๋ณด๋ฅผ ๊ฐ€๊ณตํ•ด์„œ ์ด๋ฉ”์ผ, ์•Œ๋ฆผํ†ก์„ ๋ณด๋‚ด๋Š” ๋ถ€๋ถ„์„ ๊ตฌํ˜„ํ•˜๊ฒŒ ๋˜์—ˆ๋Š”๋ฐ ๋งˆ์นจ. ํŒ€์žฅ๋‹˜์ด ์•Œ๋ฆผํ†ต์ง€์„œ๋ฒ„ ๊ฑด์„ค์„ ์ง„ํ–‰์ค‘์ด์…จ๋‹ค. ์•„์ง ์˜ˆ์•ฝ๋ฐœ์†ก ๊ธฐ๋Šฅ์ด ์—†์—ˆ๊ธฐ ๋•Œ๋ฌธ์— ์‚ด์ง์ฟต ์–น์–ด์„œ PR ํ–ˆ๋Š”๋ฐ ์ˆ˜๋งŽ์€ ๊ด€์‹ฌ๊ณผ ๋Œ“๊ธ€๋กœ ์‚ผ์ง„ ์—๋ฐ” ๊ธฐ๊ฐ ๋˜์—ˆ๋‹ค. ๊ณตํ†ต์ ์œผ๋กœ ์‚ฌ์šฉํ•˜๋Š” ๊ธฐ๋Šฅ์ด๊ธฐ ๋•Œ๋ฌธ์— ์ตœ๋Œ€ํ•œ '๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ' ์ฒ˜๋Ÿผ ๋งŒ๋“œ๋ ค๊ณ  ..

๋ฐ˜ํ™˜๊ฐ’์ด ์—†๋Š” ์„œ๋น„์Šค ํ…Œ์ŠคํŠธํ•˜๊ธฐ
TESTING 2023. 6. 28. 16:27

ํ…Œ์ŠคํŠธ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•˜๋ฉด์„œ ๋ฐ˜ํ™˜๊ฐ’ ์—†๋Š” ๋ฉ”์„œ๋“œ๋ฅผ ํ…Œ์ŠคํŠธํ•ด์•ผํ•  ๊ฒฝ์šฐ๊ฐ€ ์ƒ๊ฒผ๋‹ค. ์ด ๋ฉ”์„œ๋“œ๋Š” Message๋ฅผ ๋ณด๋‚ด๋Š” ๊ธฐ๋Šฅ์„ ํ•˜๋Š” ๋ฉ”์„œ๋“œ์ด๊ธฐ ๋•Œ๋ฌธ์— ๋‚ด๋ถ€์—์„œ ๋ฉ”์„ธ์ง€๋ฅผ ๋ณด๋‚ด๊ณ , ๋กœ๊ทธ ์ €์žฅ ํ›„ ๋ฐ˜ํ™˜ํ•˜๋Š” ๊ฐ’์ด ์—†๋‹ค. ๋‚˜๋Š” ์ด ๋‚ด๋ถ€์—์„œ ๋ฐ์ดํ„ฐ ์ •์ œ๊ฐ€ ๋๋‚œ ํ›„ ๋งˆ์ง€๋ง‰์— private send(RequestDto request) ์— ์ „๋‹ฌ๋˜๋Š” RequestDto ๋ฅผ ์•Œ๊ณ  ์‹ถ์—ˆ๋‹ค. private sendMessageList(){ // ๋ฐ์ดํ„ฐ ์ •์ œ send(reqeust); } private send(RequestDto request){ // ์‹ค์ œ๋กœ ์ „์†ก } ์ด๋•Œ, ArgumentCaptor ๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๋œ๋‹ค. @Test void sendMessageTest() { sendService.sendMessageList(new Oth..

article thumbnail
4๊ฐœ์›” ๋ฐ€๋ฆฐ ํšŒ๊ณ 
ํšŒ๊ณ  2023. 4. 24. 17:05

๊ธˆ์œต ์น˜๋ฃŒ๋ ๋•Œ๋งˆ๋‹ค ํšŒ๊ณ ๋ฅผ ์ž‘์„ฑํ•˜๊ธฐ๋กœ ๋งˆ์Œ ๋จน์—ˆ๋Š”๋ฐ ์ด๋Ÿฐ์ €๋Ÿฐ ์—…๋ฌด ํ•‘๊ณ„๋กœ ๋ฏธ๋ฃจ๋‹ค๊ฐ€ ์‹œ๊ฐ„์ด ์กฐ๊ธˆ ๋น„์–ด์„œ ์ž‘์„ฑํ•˜๊ฒŒ ๋˜์—ˆ๋‹ค. ์ตœ๊ทผ ๋ช‡๊ฐœ์›”๋™์•ˆ ์ปค๋ฆฌ์–ด๋ฆฌ ์•Œ๋žŒ์œผ๋กœ ์˜ค๋Š” ์ถ”์ฒœ ๊ฒŒ์‹œ๋ฌผ์„ ์—ด์‹ฌํžˆ ์ฝ์—ˆ๋˜ ๊ฒƒ ๊ฐ™๋‹ค. ๋ช‡๊ฐœ๋Š” ๋„ˆ๋ฌด ์ข‹์•„์„œ ์ •๋ฆฌํ•ด์„œ ๋ธ”๋กœ๊ทธ ๊ธ€์„ ์ž‘์„ฑ ํ–ˆ๊ณ  ๋ช‡๊ฐœ๋Š” ์ฝ๋‹ค๊ฐ€ ๋ถ๋งˆํฌ์—์„œ ์ฉ๋Š”์ค‘์ด๋‹ค... ์ด๋Ÿฐ ๊ธ€์„ ์•Œ๋žŒ์œผ๋กœ ๋ฐ›์•„์„œ ๋ณด๋‹ค๋ณด๋ฉด ์•Œ๋˜๊ฒƒ๋„ ํ•ญ์ƒ ์ƒˆ๋กญ๊ณ  ์ข€๋” ๊นŠ์€ ๋‚ด์šฉ์„ ๋ณด๊ฒŒ๋˜๋ฉด ์ž‘์„ฑ์ž์˜ ์ „๋ฌธ์„ฑ๊ณผ ๋งˆ์ธ๋“œ์— ์„ค๋ ˆ์ธ๋‹ค. 4์›”์— ํšŒ์‚ฌ์—์„œ ๋ชฉํ‘œ์„ค์ •๊ณผ ํ”ผ๋“œ๋ฐฑ์„ ๋ฐ›์•˜๋‹ค. ์ด๋ฒˆ ๋ถ„๊ธฐ ๋ชฉํ‘œ์— ๋Œ€ํ•ด ๊ณ ๋ฏผ์„ ๋งŽ์ด ํ–ˆ๋Š”๋ฐ ๊ธฐ์กด์„œ๋น„์Šค ๊ณ ๋„ํ™”๋ฅผ ์ดˆ์ ๋‘์—ˆ๊ณ  ์ถ”๊ฐ€์ ์œผ๋กœ ํ…Œ์ŠคํŠธ ๋„์ž…์— ๋Œ€ํ•œ ๊ธฐ๋ฐ˜์„ ๋งŒ๋“ค์–ด๋ณด๋Š”๊ฒŒ ์–ด๋–ป๋ƒ๋Š” ์ œ์•ˆ์„ ๋ฐ›์•˜๋‹ค! ์„œ๋น„์Šค ๊ฐœ๋ฐœ์ด ์•„๋‹Œ ์ฝ”๋“œ ํ’ˆ์งˆ์— ๋Œ€ํ•œ ๋ชฉํ‘œ๋ผ๋‹ˆ!!! ๐Ÿคฉ๐Ÿคฉ ๐Ÿคฉ ๊ท€ํ•˜๋‹ค ๊ท€ํ•ด ๐Ÿคฉ ๋„ˆ๋ฌด ์žฌ๋ฏธ์žˆ์„๊ฒƒ ๊ฐ™์•˜๊ณ  (๋‚ด๊ฐ€ ..

article thumbnail
๋ฉ”๋ชจ๋ฆฌ ์ ˆ์•ฝ ์Šต๊ด€ ๋“ค์ด๊ธฐ (Java Programming)
WEB/JAVA 2023. 4. 23. 19:44

Java ์˜ ์ผ๋ฐ˜์ ์ธ ๋ฌธ์ œ ์ค‘ ํ•˜๋‚˜๋Š” ๋†’์€ ๋ฉ”๋ชจ๋ฆฌ ์‚ฌ์šฉ๋Ÿ‰์œผ๋กœ ์ธํ•ด ์„ฑ๋Šฅ, ์ถฉ๋Œ์ด ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ๋‹ค๊ณ  ํ•œ๋‹ค. ์ตœ์ ํ™” ๋ฐ ๋ฉ”๋ชจ๋ฆฌ ์‚ฌ์šฉ๋Ÿ‰ ๊ฐ์†Œ๋ฅผ ์œ„ํ•œ ๋ชจ๋ฒ• ์‚ฌ๋ก€๋ฅผ ์‚ดํŽด๋ณด์ž 1. Primitive type(์›์‹œํƒ€์ž…) ์„ ์‚ฌ์šฉํ•˜์ž. ์ฐธ์กฐํƒ€์ž… ๋ณด๋‹ค ์›์‹œํƒ€์ž…์„ ์‚ฌ์šฉํ•œ๋‹ค. ์›์‹œํƒ€์ž…์„ ์‚ฌ์šฉํ•˜๋ฉด ๊ฐœ์ฒด ์ƒ์„ฑ ์˜ค๋ฒ„ํ—ค๋“œ๋ฅผ ๋ฐฉ์ง€ํ•˜์—ฌ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ์ ˆ์•ฝํ•  ์ˆ˜ ์žˆ๋‹ค. + ๋˜ํ•œ ์›์‹œํƒ€์ž…์€ ์Šคํƒ ๋ฉ”๋ชจ๋ฆฌ ์—์„œ ๋ฐ”๋กœ ์ฝ๊ณ , ์ฐธ์กฐํƒ€์ž…์€ ์Šคํƒ ๋ฉ”๋ชจ๋ฆฌ์—์„œ ํž™ ๋ฉ”๋ชจ๋ฆฌ์˜ ์œ„์น˜๋ฅผ ๊ตฌํ•ด์˜จ ๋‹ค์Œ์— ๋‹ค์‹œ ํž™ ๋ฉ”๋ชจ๋ฆฌ์— ๊ฐ€์„œ ๊ฐ’์„ ์ฝ์–ด์™€์•ผ ํ•ด์„œ ์„ฑ๋Šฅ์ƒ ์œ ๋ฆฌํ•˜๋‹ค. 2. ๋ถˆํ•„์š”ํ•œ ๊ฐ์ฒด ์ƒ์„ฑ ํ•˜์ง€๋ง์ž. String s = "์• ์ •์“ฐ"+" ์ž…๋‹ˆ๋‹ค"; ํ•ด๋‹น ์ฝ”๋“œ ํ•œ์ค„์€ "์• ์ •์“ฐ ์ž…๋‹ˆ๋‹ค" ์— ๋Œ€ํ•œ ์ƒˆ ๋ฌธ์ž์—ด ๊ฐœ์ฒด๋ฅผ ๋งŒ๋“ญ๋‹ˆ๋‹ค. ๋Œ€์‹  StringBuilder ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ฌธ์ž์—ด์„ ..