본문 바로가기

Algorithm

(2139)
(C++) - LeetCode (easy) 242. Valid Anagram https://leetcode.com/problems/valid-anagram/description/ Valid Anagram - LeetCode 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 all the original letters exactly once. E leetcode.com 간단 정렬 문제였습니다. 📕 풀이방법 📔 풀이과정 두 문자열을 사전순으로 정렬 후 같은지..
(C++) - LeetCode (easy) 234. Palindrome Linked List https://leetcode.com/problems/palindrome-linked-list/description/ Palindrome Linked List - LeetCode Palindrome Linked List - Given the head of a singly linked list, return true if it is a palindrome or false otherwise. Example 1: [https://assets.leetcode.com/uploads/2021/03/03/pal1linked-list.jpg] Input: head = [1,2,2,1] Output: true Example 2: [https leetcode.com 자료구조를 이용한 문제였습니다. 📕 풀이방법 📔 풀이과정..
(C++) - LeetCode (easy) 232. Implement Queue using Stacks https://leetcode.com/problems/implement-queue-using-stacks/description/ Implement Queue using Stacks - LeetCode Implement Queue using Stacks - Implement a first in first out (FIFO) queue using only two stacks. The implemented queue should support all the functions of a normal queue (push, peek, pop, and empty). Implement the MyQueue class: * void push(int x) Pushes leetcode.com queue를 stack 2개로 ..
(C++) - LeetCode (easy) 231. Power of Two https://leetcode.com/problems/power-of-two/description/ Power of Two - LeetCode Power of Two - Given an integer n, return true if it is a power of two. Otherwise, return false. An integer n is a power of two, if there exists an integer x such that n == 2x. Example 1: Input: n = 1 Output: true Explanation: 20 = 1 Example 2: Input: n leetcode.com 수학 관련 함수를 사용해보는 문제였습니다. 📕 풀이방법 📔 풀이과정 1. log를 씌운다고 ..
(C++) - LeetCode (easy) 228. Summary Ranges https://leetcode.com/problems/summary-ranges/description/ Summary Ranges - LeetCode Summary Ranges - You are given a sorted unique integer array nums. A range [a,b] is the set of all integers from a to b (inclusive). Return the smallest sorted list of ranges that cover all the numbers in the array exactly. That is, each element of nums is leetcode.com 구현 문제였습니다. 📕 풀이방법 📔 풀이과정 정답 vector ans를 선언해줍..
(C++) - LeetCode (easy) 226. Invert Binary Tree https://leetcode.com/problems/invert-binary-tree/description/ Invert Binary Tree - LeetCode Invert Binary Tree - Given the root of a binary tree, invert the tree, and return its root. Example 1: [https://assets.leetcode.com/uploads/2021/03/14/invert1-tree.jpg] Input: root = [4,2,7,1,3,6,9] Output: [4,7,2,9,6,3,1] Example 2: [https://assets.lee leetcode.com 자료구조 문제였습니다. 📕 풀이방법 📔 풀이과정 현재 node를 선언해..
(C++) - LeetCode (easy) 225. Implement Stack using Queues https://leetcode.com/problems/implement-stack-using-queues/description/ Implement Stack using Queues - LeetCode Implement Stack using Queues - Implement a last-in-first-out (LIFO) stack using only two queues. The implemented stack should support all the functions of a normal stack (push, top, pop, and empty). Implement the MyStack class: * void push(int x) Pushes el leetcode.com class를 활용한 자료구조 ..
(C++) - LeetCode (easy) 219. Contains Duplicate II https://leetcode.com/problems/contains-duplicate-ii/description/ Contains Duplicate II - LeetCode Contains Duplicate II - Given an integer array nums and an integer k, return true if there are two distinct indices i and j in the array such that nums[i] == nums[j] and abs(i - j)