Design Hashset in swift
[Question]: Design a HashSet without using any built-in hash table libraries. Implement MyHashSet class:
Design Hashset in swift Read More »
[Question]: Design a HashSet without using any built-in hash table libraries. Implement MyHashSet class:
Design Hashset in swift Read More »
[Question]: In an array nums and an integer k, return the total number of subarrays whose sum equals to k. Example 1: Input: nums = [1,1,1], k = 2 Output: 2 Example 2: Input: nums = [1,2,3], k = 3 Output: 2
Subarray Sum Equals K Read More »
[Question]: You are given a string ‘str’ of lowercase alphabets and an integer’k’ .Your task is to return the count all the possible substrings that have exactly ‘k’ distinct characters.For example:‘str’ = abcad and ‘k’ = 2.We can see that the substrings {ab, bc, ca, ad} are the only substrings with 2 distinct characters. Therefore,
Count number of substrings with exactly k distinct characters Read More »
[Question]: Convert given string into Integer with given condition Approach #2 Using Recursion Plain Atoi Solution
String to Integer conversion (atoi) Read More »
[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
Roman to Int conversion Read More »
[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
Maximum Nesting Depth of the Parentheses Read More »
[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”
Sort Characters By Frequency Read More »
[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:
How to check Isomorphic Strings? Read More »
[Question]: Given two string check weather they anagramExample: abc & cab are anagram Approach #2 Using Hash map / Dictionary Approach #3: Using reduce function.
Check if two strings are anagrams Read More »