Roman to Int conversion
[Question]: Convert Roman number into Int, 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 Example III = 3 IV = 4
Data structure & algorithm using swift language.
[Question]: Convert Roman number into Int, 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 Example III = 3 IV = 4
[Question]: In a given string find maximum depth of parentheses. input string has only “( )” type parenthesesExample: Input = “(1+(5*8)+((9)/2))+100” || Output = 2
[Questions]: Given a string s, sort it in decreasing order based on the frequency of the characters. for example “tree” so ee has highest appearance hence answer will be eert Return the sorted string. If there are multiple answers, return any of themInput: s = “tree”Output: “eert”
[Question]: In a given string array find the longest common prefix Example: Input [“fl”,”flower”,”flight”]Output: “fl”// because this is common prefix in the given string. #Approach Binary search We will create two pointers low & high, low starts from 0 & high is first object count. so now we will divide string into two parts and …
How to find Longest Common Prefix in strings Array Read More »
[Question]: Given two strings s and t, determine if they are isomorphic. Definition: Two strings s and t are isomorphic if the characters in s can be replaced to get t. All occurrences of a character must be replaced with another character while preserving the order of characters. No two characters may map to the same character, but a character may map to itself. Example 1: …
[Question]: Given two string check weather they anagramExample: abc & cab are anagram Approach #2 Using Hash map / Dictionary Approach #3: Using reduce function.
[Question]: Given two strings s and goal, return true if and only if s can become goal after some number of shifts on s. A shift on s consists of moving the leftmost character of s to the rightmost position. For example, if s = “abcde”, then it will be “bcdea” after one shift. Input: s = “abcde”, goal = “abced” Output: false
[Question]: In integer string Return the largest-valued odd integer (as a string) that is a non-empty substring of num, or an empty string “” if no odd integer exists. A substring is a contiguous sequence of characters within a string. Example 1: Input: num = “52” Output: “5” Explanation: The only non-empty substrings are “5”, “2”, and “52”. “5” is the only odd number input …
[Question] Given a string s, reverse the words of the string.Note: Remove extra spaces from output Examples: Example 1: Input: s=”My Name is Janesh” Output: “Janesh is Name My” Example 2: Input: s= ” My Name is Janesh” Output: “Janesh is Name My”
[Question]: A valid parentheses string is either empty “”, “(” + A + “)”, or A + B, where A and B are valid parentheses strings, and + represents string concatenation. For example, “”, “()”, “(())()”, and “(()(()))” are all valid parentheses strings. Return s after removing the outermost parentheses of every primitive string in the primitive decomposition of s. Example 1: Input: s = “(()())(())” Output: “()()()” Explanation: The input string …