๐Ÿ–ฅ๏ธ Computer

๋ฌธ์ œ ์—๋ผํ† ์Šคํ…Œ๋„ค์Šค์˜ ์ฒด๋Š” N๋ณด๋‹ค ์ž‘๊ฑฐ๋‚˜ ๊ฐ™์€ ๋ชจ๋“  ์†Œ์ˆ˜๋ฅผ ์ฐพ๋Š” ์œ ๋ช…ํ•œ ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด๋‹ค. ์ด ์•Œ๊ณ ๋ฆฌ์ฆ˜์€ ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค. 2๋ถ€ํ„ฐ N๊นŒ์ง€ ๋ชจ๋“  ์ •์ˆ˜๋ฅผ ์ ๋Š”๋‹ค. ์•„์ง ์ง€์šฐ์ง€ ์•Š์€ ์ˆ˜ ์ค‘ ๊ฐ€์žฅ ์ž‘์€ ์ˆ˜๋ฅผ ์ฐพ๋Š”๋‹ค. ์ด๊ฒƒ์„ P๋ผ๊ณ  ํ•˜๊ณ , ์ด ์ˆ˜๋Š” ์†Œ์ˆ˜์ด๋‹ค. P๋ฅผ ์ง€์šฐ๊ณ , ์•„์ง ์ง€์šฐ์ง€ ์•Š์€ P์˜ ๋ฐฐ์ˆ˜๋ฅผ ํฌ๊ธฐ ์ˆœ์„œ๋Œ€๋กœ ์ง€์šด๋‹ค. ์•„์ง ๋ชจ๋“  ์ˆ˜๋ฅผ ์ง€์šฐ์ง€ ์•Š์•˜๋‹ค๋ฉด, ๋‹ค์‹œ 2๋ฒˆ ๋‹จ๊ณ„๋กœ ๊ฐ„๋‹ค. N, K๊ฐ€ ์ฃผ์–ด์กŒ์„ ๋•Œ, K๋ฒˆ์งธ ์ง€์šฐ๋Š” ์ˆ˜๋ฅผ ๊ตฌํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค. ์ž…๋ ฅ ์ฒซ์งธ ์ค„์— N๊ณผ K๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. (1 ≤ K < N, max(2, K) < N ≤ 1000) ์ถœ๋ ฅ ์ฒซ์งธ ์ค„์— K๋ฒˆ์งธ ์ง€์›Œ์ง„ ์ˆ˜๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค. ์˜ˆ์ œ ์ž…๋ ฅ 1 10 7 ์˜ˆ์ œ ์ถœ๋ ฅ 1 9 ํžŒํŠธ 2, 4, 6, 8, 10, 3, 9, 5, 7 ์ˆœ์„œ๋Œ€๋กœ ์ง€์›Œ์ง„๋‹ค. 7๋ฒˆ์งธ ์ง€..
Given two strings s and t which consist of only lowercase letters. String t is generated by random shuffling string s and then add one more letter at a random position. Find the letter that was added in t. Example: Input: s = "abcd" t = "abcde" Output: e Explanation: 'e' is the letter that was added. ์ฝ”๋“œ class Solution { public: char findTheDifference(string s, string t) { long int arr1[27] = {0,..
Given a positive integer n and you can do operations as follow: If n is even, replace n with n/2. If n is odd, you can replace n with either n + 1 or n - 1. What is the minimum number of replacements needed for n to become 1? Example 1: Input: 8 Output: 3 Explanation: 8 -> 4 -> 2 -> 1 Example 2: Input: 7 Output: 4 Explanation: 7 -> 8 -> 4 -> 2 -> 1 or 7 -> 6 -> 3 -> 2 -> 1 ์ฝ”๋“œ class Solution { pu..
You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous version, all the versions after a bad version are also bad. Suppose you have n versions [1, 2, ..., n] and you want to find out the first bad one, which causes all the following ones to be..
7. Reverse Integer Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Output: 321 Example 2: Input: -123 Output: -321 Example 3: Input: 120 Output: 21 Note: Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−231, 231 − 1]. For the purpose of this problem, assume that your function returns 0 when the ..
๋ฌธ์ œ ์šฐ๋ฆฌ๋Š” ์‚ฌ๋žŒ์˜ ๋ฉ์น˜๋ฅผ ํ‚ค์™€ ๋ชธ๋ฌด๊ฒŒ, ์ด ๋‘ ๊ฐœ์˜ ๊ฐ’์œผ๋กœ ํ‘œํ˜„ํ•˜์—ฌ ๊ทธ ๋“ฑ์ˆ˜๋ฅผ ๋งค๊ฒจ๋ณด๋ ค๊ณ  ํ•œ๋‹ค. ์–ด๋–ค ์‚ฌ๋žŒ์˜ ๋ชธ๋ฌด๊ฒŒ๊ฐ€ x kg์ด๊ณ  ํ‚ค๊ฐ€ y cm๋ผ๋ฉด ์ด ์‚ฌ๋žŒ์˜ ๋ฉ์น˜๋Š” (x,y)๋กœ ํ‘œ์‹œ๋œ๋‹ค. ๋‘ ์‚ฌ๋žŒ A ์™€ B์˜ ๋ฉ์น˜๊ฐ€ ๊ฐ๊ฐ (x,y), (p,q)๋ผ๊ณ  ํ•  ๋•Œ x>p ๊ทธ๋ฆฌ๊ณ  y>q ์ด๋ผ๋ฉด ์šฐ๋ฆฌ๋Š” A์˜ ๋ฉ์น˜๊ฐ€ B์˜ ๋ฉ์น˜๋ณด๋‹ค "๋” ํฌ๋‹ค"๊ณ  ๋งํ•œ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด ์–ด๋–ค A, B ๋‘ ์‚ฌ๋žŒ์˜ ๋ฉ์น˜๊ฐ€ ๊ฐ๊ฐ (56,177), (45,165) ๋ผ๊ณ  ํ•œ๋‹ค๋ฉด A์˜ ๋ฉ์น˜๊ฐ€ B๋ณด๋‹ค ํฐ ์…ˆ์ด ๋œ๋‹ค. ๊ทธ๋Ÿฐ๋ฐ ์„œ๋กœ ๋‹ค๋ฅธ ๋ฉ์น˜๋ผ๋ฆฌ ํฌ๊ธฐ๋ฅผ ์ •ํ•  ์ˆ˜ ์—†๋Š” ๊ฒฝ์šฐ๋„ ์žˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด ๋‘ ์‚ฌ๋žŒ C์™€ D์˜ ๋ฉ์น˜๊ฐ€ ๊ฐ๊ฐ (45, 181), (55,173)์ด๋ผ๋ฉด ๋ชธ๋ฌด๊ฒŒ๋Š” D๊ฐ€ C๋ณด๋‹ค ๋” ๋ฌด๊ฒ๊ณ , ํ‚ค๋Š” C๊ฐ€ ๋” ํฌ๋ฏ€๋กœ, "๋ฉ์น˜"๋กœ๋งŒ ๋ณผ ๋•Œ C์™€ D๋Š” ๋ˆ„..
_์ฃผ๋…ธ
'๐Ÿ–ฅ๏ธ Computer' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๊ธ€ ๋ชฉ๋ก (3 Page)