본문 바로가기

Algorithm

(5)
[LeetCode] 20. Valid Parentheses 1. Description Givian a string s containing just the characters '(', ')', '{', '}', '[', and ']', determine if the input string is valid. An input string is valid if : Open bracket must be closed by the same type of brackets Open brackets must be closed in the correct order. Every closed bracket has a corresponding bracket of the same type. constraints : 1 check if the current element is same wi..
[LeetCode] 14. Longest Common Prefix 1. Description Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string "". constraints : 1
[LeetCode] 13. Roman to Integer 1. Description Roman numericals are represented by seven different symbols : I, V, X, L, C, D, and M. Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 For example, 2 is written II in Roman numeral, just two ones added together, 12 is written as XII, which is simply X + II. The number 27 is written as XXVII, which is XX + V + II. Roman numerals are usually written largest to smallest from left t..
[LeetCode] 9. Palindrome Number 1. Description 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. constraints : \(-2^{31} 12 - backward += x % 10 -> 1 - backward = backward * 10 -> 10 iteration2 : - x % 10 -> 2 - x // 10 -> 1 - backward += x % 10 -> 12 Start If x 0 and x % 10 == 0), ret..
[LeetCode] 1. Two Sum 1. Description Given an array of integers nums and an integer target, return indices of two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order. constraints : 2