๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
728x90
300x250

Algorithm32

[LeetCode] 35. Search Insert Position 35. Search Insert Position Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You must write an algorithm with O(log n) runtime complexity. Example 1: Input: nums = [1,3,5,6], target = 5 Output: 2 Example 2: Input: nums = [1,3,5,6], target = 2 Output: 1 Example 3: Input: n.. 2022. 4. 20.
[LeetCode] 3. Longest Substring Without Repeating Characters Given a string s, find the length of the longest substring without repeating characters. Example 1: Input: s = "abcabcbb" Output: 3 Explanation: The answer is "abc", with the length of 3. Example 2: Input: s = "bbbbb" Output: 1 Explanation: The answer is "b", with the length of 1. Example 3: Input: s = "pwwkew" Output: 3 Explanation: The answer is "wke", with the length of 3. Notice that the ans.. 2022. 4. 18.
[LeetCode] 58. Length of Last Word 58. Length of Last Word Given a string s consisting of some words separated by some number of spaces, return the length of the last word in the string. A word is a maximal substring consisting of non-space characters only. Example 1: Input: s = "Hello World" Output: 5 Explanation: The last word is "World" with length 5. Example 2: Input: s = " fly me to the moon " Output: 4 Explanation: The last.. 2022. 4. 17.
[LeetCode] 9. Palindrome Number ๐Ÿ“–๋ฌธ์ œ. ์ˆซ์ž๊ฐ€ ์ž…๋ ฅ๋˜๋ฉด ํ•ด๋‹น ์ˆซ์ž๊ฐ€ ํŒฐ๋ฆฐ๋“œ๋กฌ์ด๋ฉด true, ์•„๋‹ˆ๋ฉด false ๋ฅผ ์ถœ๋ ฅํ•˜์„ธ์š”. Given an integer x, return true if x is palindrome integer. An integer is a palindrome when it reads the same backward as forward. For example, 121 is a palindrome while 123 is not. Example 1: Input: x = 121 Output: true Explanation: 121 reads as 121 from left to right and from right to left. Example 2: Input: x = -121 Output: false Explanatio.. 2022. 4. 17.
[LeetCode] ๋ฆฟ์ฝ”๋“œ ์‹œ์ž‘ํ•˜๊ธฐ, Github์— ์ž๋™ ์ปค๋ฐ‹(LeetHub) ๋ฐฉ๋ฒ• https://leetcode.com/ 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 LeetCode๋Š” ์ „์„ธ๊ณ„์ ์œผ๋กœ ์œ ๋ช…ํ•œ Online Judge Platform ์ž…๋‹ˆ๋‹ค. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์—์„œ๋„ ์ด๊ณณ ๋ฌธ์ œ๋ฅผ ๋ณ€ํ˜•ํ•ด์„œ ์ถœ์ œ๋˜๋Š” ๋ฌธ์ œ๊ฐ€ ๋งŽ์•˜์Šต๋‹ˆ๋‹ค. ๊ตฌ๊ธ€/๊นƒํ—ˆ๋ธŒ/ํŽ˜์ด์Šค๋ถ ๊ณ„์ •์œผ๋กœ ๊ฐ„ํŽธํ•˜๊ฒŒ ๊ฐ€์ž…ํ›„ ์‚ฌ์šฉ ํ•˜์‹ค์ˆ˜์žˆ์Šต๋‹ˆ๋‹ค. โœจLeetHub : Github ์— ์ž๋™์œผ๋กœ Comm.. 2022. 4. 16.
2021 KAKAO ๋ธ”๋ผ์ธ๋“œ ์ฝ”๋”ฉํ…Œ์ŠคํŠธ - ์‹ ๊ทœ ์•„์ด๋”” ์ถ”์ฒœ ์‹ ๊ทœ ์•„์ด๋”” ์ถ”์ฒœ ์นด์นด์˜ค์— ์ž…์‚ฌํ•œ ์‹ ์ž… ๊ฐœ๋ฐœ์ž ๋„ค์˜ค๋Š” "์นด์นด์˜ค๊ณ„์ •๊ฐœ๋ฐœํŒ€"์— ๋ฐฐ์น˜๋˜์–ด, ์นด์นด์˜ค ์„œ๋น„์Šค์— ๊ฐ€์ž…ํ•˜๋Š” ์œ ์ €๋“ค์˜ ์•„์ด๋””๋ฅผ ์ƒ์„ฑํ•˜๋Š” ์—…๋ฌด๋ฅผ ๋‹ด๋‹นํ•˜๊ฒŒ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. "๋„ค์˜ค"์—๊ฒŒ ์ฃผ์–ด์ง„ ์ฒซ ์—…๋ฌด๋Š” ์ƒˆ๋กœ ๊ฐ€์ž…ํ•˜๋Š” ์œ ์ €๋“ค์ด ์นด์นด์˜ค ์•„์ด๋”” ๊ทœ์น™์— ๋งž์ง€ ์•Š๋Š” ์•„์ด๋””๋ฅผ ์ž…๋ ฅํ–ˆ์„ ๋•Œ, ์ž…๋ ฅ๋œ ์•„์ด๋””์™€ ์œ ์‚ฌํ•˜๋ฉด์„œ ๊ทœ์น™์— ๋งž๋Š” ์•„์ด๋””๋ฅผ ์ถ”์ฒœํ•ด์ฃผ๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ๊ฐœ๋ฐœํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. ๋‹ค์Œ์€ ์นด์นด์˜ค ์•„์ด๋””์˜ ๊ทœ์น™์ž…๋‹ˆ๋‹ค. ์•„์ด๋””์˜ ๊ธธ์ด๋Š” 3์ž ์ด์ƒ 15์ž ์ดํ•˜์—ฌ์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์•„์ด๋””๋Š” ์•ŒํŒŒ๋ฒณ ์†Œ๋ฌธ์ž, ์ˆซ์ž, ๋นผ๊ธฐ(-), ๋ฐ‘์ค„(_), ๋งˆ์นจํ‘œ(.) ๋ฌธ์ž๋งŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋‹จ, ๋งˆ์นจํ‘œ(.)๋Š” ์ฒ˜์Œ๊ณผ ๋์— ์‚ฌ์šฉํ•  ์ˆ˜ ์—†์œผ๋ฉฐ ๋˜ํ•œ ์—ฐ์†์œผ๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. "๋„ค์˜ค"๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์ด 7๋‹จ๊ณ„์˜ ์ˆœ์ฐจ์ ์ธ ์ฒ˜๋ฆฌ ๊ณผ์ •์„ ํ†ตํ•ด ์‹ ๊ทœ ์œ ์ €๊ฐ€ ์ž…๋ ฅ.. 2022. 4. 13.
[๊ตฌ๊ธ€์ฝ”ํ…Œ] GOCC48 - Coding - SWE Intern (Seoul) questions1, 2 ์•ˆ๋…•ํ•˜์„ธ์š” yunamom ์ž…๋‹ˆ๋‹ค ๐Ÿ˜Š Google’s Online Challenge [LIVE @ 09:00 KST] GOCC48 - Coding - SWE Intern (Seoul) ๋ฌธ์ œ1 / ๋ฌธ์ œ2 ํฌ์ŠคํŒ…ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค :D ๊ตฌ๊ธ€์ฝ”๋ฆฌ์•„ ์ง€๋งŒ ๋ชจ๋“  ๊ณผ์ •์€ ์˜์–ด๋‹ค! ๋‹ค๋ฅธ ํ™”๋ฉด ํด๋ฆญ์‹œ ๋ฐ”๋กœ ํ™”๋ฉด์ดํƒˆํ•˜๋ฉด ๋กœ๊ทธ์•„์›ƒ๋œ๋‹ค๊ตฌ ๊ฒฝ๊ณ ์ฐฝ์ด ๋œฌ๋‹ค. (๋ฌธ์ œ ๋ณต์‚ฌ X, ์ฝ”๋“œ๋ธ”๋Ÿญ์— ๋ณต๋ถ™๋„ X, ๋“€์–ผ๋ชจ๋‹ˆํ„ฐ X) ๐Ÿ“– ๋ฌธ์ œ 1. ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ๋ณธ ์‚ฌ์ดํŠธ๋Š” Hackerearth ์ž…๋‹ˆ๋‹ค. LeetCode ๋Š” ๋งŽ์ด ๋“ค์–ด๋ณด์•˜๋Š”๋ฐ Hackerearth ์ด๊ณณ์€ ์ด๋ฒˆ์— ์ฒ˜์Œ๋ดค๋‹ค.. ๐Ÿ“– ๋ฌธ์ œ 2. ๋ฌธ์ œ2 ๊ฐ™์€ ๊ฒฝ์šฐ์—๋Š” ํ’€์ด๋ฅผ ํ•˜์ž๋ฉด, ๋‘๋ฐฐ์—ด์„ ํ•ฉ์นœํ›„ ์ œ์ผํฐ์ˆ˜, ์ œ์ผ์ž‘์€์ˆ˜ ์„ ๊ตฌํ•œ๋’ค์— max = 1+(์ œ์ผํฐ์ˆ˜*๋ฐฐ์—ด๊ธธ์ด-1); min = 1+(์ œ์ผ์ž‘์€์ˆ˜*๋ฐฐ์—ด๊ธธ.. 2022. 4. 9.
[๊ตฌ๊ธ€์ฝ”ํ…Œ] GOCC48 - Coding - SWE Intern (Seoul) ํ›„๊ธฐ ์•ˆ๋…•ํ•˜์„ธ์š” yunamom ์ž…๋‹ˆ๋‹ค :D ์ €๋ฒˆ์ฃผ์— ๊ตฌ๊ธ€์ฝ”๋ฆฌ์•„ ์†Œํ”„ํŠธ์›จ์–ด ์—”์ง€๋‹ˆ์–ด ์ธํ„ด ์ ‘์ˆ˜ํ›„ ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์ผ์ •์— ๊ด€ํ•œ ์ด๋ฉ”์ผ์„ ๋ฐ›์•˜๋Š”๋ฐ์š”. Google’s Online Challenge [LIVE @ 09:00 KST] 2022๋…„ 4์›” 8์ผ(๊ธˆ) ์˜ค์ „ 9์‹œ ๋ฐ”๋กœ! ์˜ค๋Š˜ ์˜จ๋ผ์ธ์ฝ”๋”ฉํ…Œ์ŠคํŠธ๋ฅผ ์น˜๋ฃฌ ํ›„๊ธฐ๋ฅผ ํฌ์ŠคํŒ…ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค ๐Ÿ˜Š ์—ฐ์Šต๋งํฌ : ํด๋ฆญ (๊ฐ€์ž…ํ›„ ์ด์šฉํ•˜์‹ค์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. gmail, github ๋“ฑ๋“ฑ) ๊ตฌ๊ธ€์ฝ”๋ฆฌ์•„ ์ง€๋งŒ ๋ชจ๋“  ๊ณผ์ •์€ ์˜์–ด๋‹ค! ๋‹ค๋ฅธ ํ™”๋ฉด ํด๋ฆญ์‹œ ๋ฐ”๋กœ ํ™”๋ฉด์ดํƒˆํ•˜๋ฉด ๋กœ๊ทธ์•„์›ƒ๋œ๋‹ค๊ตฌ ๊ฒฝ๊ณ ์ฐฝ์ด ๋œฌ๋‹ค. (์ฝ”๋“œ๋ธ”๋Ÿญ์— ๋ณต๋ถ™๋„ X) ์ฒซ๋ฒˆ์งธ ๋ฌธ์ œ๋Š” ์ œ๋Œ€๋กœ ํ’€์ง€๋„ ๋ชปํ–ˆ๋‹ค.. ( ์ง€๋ฌธ์ด ์ดํ•ด๊ฐ€ ์•ˆ๊ฐ”์Œ๐Ÿ˜ข ) ๐Ÿ’ก์ฝ”๋”ฉํ…Œ์ŠคํŠธ ๋ณธ ์‚ฌ์ดํŠธ๋Š” Hackerearth ์ด๋‹ค. LeetCode ๋Š” ๋งŽ์ด ๋“ค์–ด๋ณด์•˜๋Š”๋ฐ Hackerearth ์ด๊ณณ์€.. 2022. 4. 8.
[JAVA] ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค - ํ•ธ๋“œํฐ๋ฒˆํ˜ธ๊ฐ€๋ฆฌ๊ธฐ ํ•ธ๋“œํฐ ๋ฒˆํ˜ธ ๊ฐ€๋ฆฌ๊ธฐ ๐Ÿ’ก๋ฌธ์ œ ์„ค๋ช… ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ๋ชจ๋ฐ”์ผ์€ ๊ฐœ์ธ์ •๋ณด ๋ณดํ˜ธ๋ฅผ ์œ„ํ•ด ๊ณ ์ง€์„œ๋ฅผ ๋ณด๋‚ผ ๋•Œ ๊ณ ๊ฐ๋“ค์˜ ์ „ํ™”๋ฒˆํ˜ธ์˜ ์ผ๋ถ€๋ฅผ ๊ฐ€๋ฆฝ๋‹ˆ๋‹ค. ์ „ํ™”๋ฒˆํ˜ธ๊ฐ€ ๋ฌธ์ž์—ด phone_number๋กœ ์ฃผ์–ด์กŒ์„ ๋•Œ, ์ „ํ™”๋ฒˆํ˜ธ์˜ ๋’ท 4์ž๋ฆฌ๋ฅผ ์ œ์™ธํ•œ ๋‚˜๋จธ์ง€ ์ˆซ์ž๋ฅผ ์ „๋ถ€ *์œผ๋กœ ๊ฐ€๋ฆฐ ๋ฌธ์ž์—ด์„ ๋ฆฌํ„ดํ•˜๋Š” ํ•จ์ˆ˜, solution์„ ์™„์„ฑํ•ด์ฃผ์„ธ์š”. ์ œํ•œ ์กฐ๊ฑด phone_number๋Š” ๊ธธ์ด 4 ์ด์ƒ, 20์ดํ•˜์ธ ๋ฌธ์ž์—ด์ž…๋‹ˆ๋‹ค. ์ž…์ถœ๋ ฅ ์˜ˆ phone_number return "01033334444" "*******4444" "027778888" "*****8888" package ํ•ธ๋“œํฐ๋ฒˆํ˜ธ๊ฐ€๋ฆฌ๊ธฐ; class Solution { public String solution(String phone_number) { String answer = ""; for(.. 2022. 4. 6.
728x90
300x250

์ฝ”๋“œ