EASY

Minimum Cost to Merge Stones

Valid Parentheses LeetCode Solution | Easy Approach

Valid Parentheses | Given a string s containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[‘ and ‘]’, determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of brackets. Open brackets must be closed in the correct order. Example 1: Input: s = “()” Output: true Example 2: Input: s = …

Valid Parentheses LeetCode Solution | Easy Approach Read More »

Minimum Cost to Merge Stones

Longest Common Prefix LeetCode Solution | Easy Approach

Longest Common Prefix | 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 “”. Example 1: Input: strs = [“flower”,”flow”,”flight”] Output: “fl” Example 2: Input: strs = [“dog”,”racecar”,”car”] Output: “” Explanation: There is no common prefix among the input strings. …

Longest Common Prefix LeetCode Solution | Easy Approach Read More »

Minimum Cost to Merge Stones

Roman to Integer LeetCode Solution | Easy Approach

Roman to Integer | Roman numerals 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 as II in Roman numeral, just two one’s added together. 12 is written as XII, which is simply X + II. The number 27 is written as XXVII, which is XX + V + …

Roman to Integer LeetCode Solution | Easy Approach Read More »

Palindrome Number Leetcode Solution | Easy Approach

Palindrome Number Leetcode | 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. Example 1: Input: x = 121 Output: true Explanation: 121 reads as 121 from left to right and from right to left. Example 2: Input: x = -121 …

Palindrome Number Leetcode Solution | Easy Approach Read More »

Two Sum Leetcode Optimal Solution | C++ | Java | Python

Given an array of integers nums and an integer target, return indices of the 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. Example 1: Input: nums = [2,7,11,15], target = 9 Output: [0,1] Explanation: Because …

Two Sum Leetcode Optimal Solution | C++ | Java | Python Read More »

x