Zeta Internship|OA| OffCampus for 2022 Grads

There Are 3 Questions In 1.5 Hours.

  1. -https://leetcode.com/problems/smallest-k-length-subsequence-with-occurrences-of-a-letter/
    The question was similar to the one mentioned above just it had one change that the string consists of only two char 'a' and 'b'.
    Given A String Consist Only 2 char 'a' and 'b'. Your Have To Find Lexicographically Smaller Subsequence Of Length K with Minimum Of X Number Of 'b' char.
    Ex. s='abab' k=3 X=2
    ans='abb'

  2. :-Variation of Dijkstra Algorithm though it was a simple one.Undirected GraphThe question said Value of path =Maximum of(absolute diff. between values of adjacent node in Path.We will be a start node and end node we had to find minimum possible value of path which starts with S and ends with E.
    Test Case:-
    N=5,M=6 {number of lines which denotes edge between two nodes}S=1 E=4 A[i]={3,12,4,7,13}[where A represents values of nodes in graph G}
    edges are
    1 2
    1 3
    2 4
    2 5
    3 4
    3 5
    So ans:- is 3 from node 1-3-4

  3. You Are Given To Int Array A And B Of Length n. And For A[i] (0<i<n) You Can Take Any B[j] (0<j<n) And Take Opration Of A[i]= A[i]+B[j] or A[i]=A[i]B[j].(Note: You Can Take Any Element Of B AtMost 1 Time). And Then Multiple All Element Of A With Module of 1000000007.
    Test case:- N=2
    a[i]= 2 3
    b[i]= 2 1
    ans=18
    a[0]=2+1
    a[1]=3
    2 finally 6*3=18

Please upvote the answer!

Comments (1)