ABOUT ME

My photo
Rajahmundry, AndhraPradesh, India

Wipro NLTH Jan 2021 Coding Questions

 Question No 1:

            An e-commerce website wishes to analyze. the per-day sales of their products. The products are tagged from a to z and A to Z. The daily sales are merged into a sequence of the tags of the products sold in the day. The company wishes to identify the products that are purchased only one time in the day.


Write an algorithm to find the count of the product tags that occur only once in the sales sequence.

Input

The input consists of a string saleSequence representing sales of the day.


Output

Print an integer representing the count of the product tags that occur only once in the sales sequence.


Note

The Input string saleSequence is case sensitive. Uppercase characters and lowercase characters are counted as different.


Example

Input:
    alphaadida

Output:
    4

Explanation:
    The product tags that occurred once in the sales
sequences are l,p,h,i. so the output is 4.


NOTE-- Wipro 2021 using python 2.7 version.



        inp=raw_input()
        c=0
        for i in inp:
            if inp.count(i)==1:
                c+=1
        print(c)
  

Wipro NLTH Previous Coding Questions

Question No 1: Check For Balanced Parenthesis.

Examples:

Input : {[]{()}}
Output : Balanced

Input : [{}{}(]
Output : Unbalanced
    inp=input()
    l=list()
    par_list={"{":"}","(":")","[":"]","}":"{",")":"(","]":"["}
    open_list=["{","(","["]
    closed_list=["}",")","]"]
    i=0
    while i<len(inp):
        if inp[i] in open_list:
            l.append(inp[i])
            i+=1
        elif inp[i] in closed_list:
            if par_list[inp[i]]==l[-1]:
                l.pop()
                i+=1
            else:
                break
    if len(l)==0:
        print("BALANCED PARANTHESIS")
    else:
        print("UNBALANCED PARANTHESIS") 

Question No 2: Print a given matrix in spiral form.

Given a 2D array, print it in spiral form. See the following examples.
Input:
        1    2   3   4
        5    6   7   8
        9   10  11  12
        13  14  15  16 
Output: 
1 2 3 4 8 12 16 15 14 13 9 5 6 7 11 10 
Input:
        1   2   3   4  5   6
        7   8   9  10  11  12
        13  14  15 16  17  18 
Output: 
1 2 3 4 5 6 12 18 17 16 15 14 13 7 8 9 10 11


def spiralPrint(m,n,a): 
    k=0;l=0
#k - starting row index 
#m - ending row index 
#l - starting column index 
#n - ending column index 
#i - iterator
    while (k<m and l<n): 
    # Print the first row from 
    # the remaining rows 
        for i in range(l,n) : 
            print(a[k][i],end=" ") 
        k+=1
        # Print the last column from 
        # the remaining columns 
        for i in range(k,m) : 
            print(a[i][n-1],end = " ") 
        n-=1
        # Print the last row from 
        # the remaining rows 
        if (k<m) : 
            for i in range(n-1,(l-1),-1) : 
                print(a[m-1][i],end=" ")
        m-=1

        # Print the first column from 
        # the remaining columns 
        if (l<n) : 
            for i in range(m-1,k-1,-1) : 
                print(a[i][l],end=" ")
        l+=1

# Driver Code 
a = [ [1, 2, 3, 4, 5, 6], 
[7, 8, 9, 10, 11, 12], 
[13, 14, 15, 16, 17, 18] ] 

R = 3; C = 6
spiralPrint(R, C, a)