본문 바로가기

Algorithm/Implementation

(750)
(C++) - LeetCode (easy) 409. Longest Palindrome https://leetcode.com/problems/longest-palindrome/description/ Longest Palindrome - LeetCode Can you solve this real interview question? Longest Palindrome - Given a string s which consists of lowercase or uppercase letters, return the length of the longest palindrome that can be built with those letters. Letters are case sensitive, for example, leetcode.com 자료구조를 이용한 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 1...
(C++) - LeetCode (easy) 405. Convert a Number to Hexadecimal https://leetcode.com/problems/convert-a-number-to-hexadecimal/description/ Convert a Number to Hexadecimal - LeetCode Can you solve this real interview question? Convert a Number to Hexadecimal - Given an integer num, return a string representing its hexadecimal representation. For negative integers, two’s complement [https://en.wikipedia.org/wiki/Two%27s_complement] me leetcode.com 16진수 구현 문제였습..
(C++) - LeetCode (easy) 342. Power of Four https://leetcode.com/problems/power-of-four/description/ Power of Four - LeetCode Power of Four - Given an integer n, return true if it is a power of four. Otherwise, return false. An integer n is a power of four, if there exists an integer x such that n == 4x. Example 1: Input: n = 16 Output: true Example 2: Input: n = 5 Output: fal leetcode.com 구현 문제였습니다. 📕 풀이방법 📔 풀이과정 1. 자료형이 int를 넘어갈 수 있으므로 ..
(C++) - LeetCode (easy) 338. Counting Bits https://leetcode.com/problems/counting-bits/description/ Counting Bits - LeetCode Can you solve this real interview question? Counting Bits - Given an integer n, return an array ans of length n + 1 such that for each i (0
(C++) - LeetCode (easy) 326. Power of Three https://leetcode.com/problems/power-of-three/description/ Power of Three - LeetCode Power of Three - Given an integer n, return true if it is a power of three. Otherwise, return false. An integer n is a power of three, if there exists an integer x such that n == 3x. Example 1: Input: n = 27 Output: true Explanation: 27 = 33 Example 2: leetcode.com 구현 문제였습니다. 📕 풀이방법 📔 풀이과정 i가 n보다 작은 동안 3씩 곱해주며 n과..
(C++) - LeetCode (easy) 292. Nim Game https://leetcode.com/problems/nim-game/description/ Nim Game - LeetCode Nim Game - You are playing the following Nim Game with your friend: * Initially, there is a heap of stones on the table. * You and your friend will alternate taking turns, and you go first. * On each turn, the person whose turn it is will remove 1 to 3 sto leetcode.com 공식을 알아내 푸는 문제였습니다. 📕 풀이방법 📔 풀이과정 2^31까지 제한을 두므로 O(n)으로도 ..
(C++) - LeetCode (easy) 1470. Shuffle the Array https://leetcode.com/problems/shuffle-the-array/description/ Shuffle the Array - LeetCode Shuffle the Array - Given the array nums consisting of 2n elements in the form [x1,x2,...,xn,y1,y2,...,yn]. Return the array in the form [x1,y1,x2,y2,...,xn,yn]. Example 1: Input: nums = [2,5,1,3,4,7], n = 3 Output: [2,3,5,4,1,7] Explanation: Since x1=2 leetcode.com 간단 구현 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 정답 변수 vec..
(C++) - LeetCode (easy) 283. Move Zeroes https://leetcode.com/problems/move-zeroes/description/ Move Zeroes - LeetCode Move Zeroes - Given an integer array nums, move all 0's to the end of it while maintaining the relative order of the non-zero elements. Note that you must do this in-place without making a copy of the array. Example 1: Input: nums = [0,1,0,3,12] Output: leetcode.com 구현 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 0인 마지막 index를 저장할 변수 zer..