본문 바로가기

Algorithm/자료구조

(126)
(C++) - LeetCode (easy) 448. Find All Numbers Disappeared in an Array 구현 문제였습니다. https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array/description/ Find All Numbers Disappeared in an Array - LeetCode Can you solve this real interview question? Find All Numbers Disappeared in an Array - Given an array nums of n integers where nums[i] is in the range [1, n], return an array of all the integers in the range [1, n] that do not appear in nums. Example ..
(C++) - LeetCode (easy) 414. Third Maximum Number https://leetcode.com/problems/third-maximum-number/description/ Third Maximum Number - LeetCode Can you solve this real interview question? Third Maximum Number - Given an integer array nums, return the third distinct maximum number in this array. If the third maximum does not exist, return the maximum number. Example 1: Input: nums = [3,2,1] Outp leetcode.com set을 이용해 푼 문제였습니다. 📕 풀이방법 📔 풀이과정 1...
(C++) - LeetCode (easy) 387. First Unique Character in a String https://leetcode.com/problems/first-unique-character-in-a-string/description/ First Unique Character in a String - LeetCode Can you solve this real interview question? First Unique Character in a String - Given a string s, find the first non-repeating character in it and return its index. If it does not exist, return -1. Example 1: Input: s = "leetcode" Output: 0 Example 2: leetcode.com 간단 구현 문제..
(C++) - LeetCode (easy) 383. Ransom Note https://leetcode.com/problems/ransom-note/description/ Ransom Note - LeetCode Ransom Note - Given two strings ransomNote and magazine, return true if ransomNote can be constructed by using the letters from magazine and false otherwise. Each letter in magazine can only be used once in ransomNote. Example 1: Input: ransomNote = "a" leetcode.com 자료구조를 이용한 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 magazine에 나온 alph..
(C++) - LeetCode (easy) 783. Minimum Distance Between BST Nodes https://leetcode.com/problems/minimum-distance-between-bst-nodes/description/ Minimum Distance Between BST Nodes - LeetCode Can you solve this real interview question? Minimum Distance Between BST Nodes - Given the root of a Binary Search Tree (BST), return the minimum difference between the values of any two different nodes in the tree. Example 1: [https://assets.leetcode.c 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) 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를 선언해..