InfyTQ Practice Problem - Day 21
InfyTQ Practice Problem - Day 21
Given a string S, find length of the longest substring with all distinct characters.
Example 1:
Input:
S = "geeksforgeeks"
Output: 7
​Example 2:
Input:
S = "aaa"
Output: 1
Your Task:
You don't need to read input or print anything. Your task is to complete the
function longestSubstrDitinctChars() which takes the string S as input and returns the length of the longest
Constraints:
1<=|S|<=105
Question 2: Reverse words in a given string
Given a String S, reverse the string without reversing its individual words. Words are separated by dots.
Example 1:
Input:
S = i.like.this.program.very.much
Output: much.very.program.this.like.i
string becomes
much.very.program.this.like.i
Example 2:
Input:
S = pqr.mno
Output: mno.pqr
mno.pqr
Your Task:
You dont need to read input or print anything. Complete the function reverseWords() which takes string S as
input parameter and returns a string containing the words in reversed order. Each word in the returning string
Constraints:
Given two arrays: a1[0..n-1] of size n and a2[0..m-1] of size m. Task is to check whether a2[] is a subset of a1[]
Example 1:
Input:
a2[] = {11, 3, 7, 1}
Output:
Yes
Explanation:
Example 2:
Input:
a1[] = {1, 2, 3, 4, 5, 6}
a2[] = {1, 2, 4}
Output:
Yes
Explanation:
Example 3:
Input:
a2[] = {19, 5, 3}
Output:
No
Explanation:
You don't need to read input or print anything. Your task is to complete the function isSubset() which takes the
array a1[], a2[], its size n and m as inputs and return "Yes" if arr2 is subset of arr1 else return "No" if arr2 is not
subset of arr1.
Constraints: