ABOUT ME

My photo
Rajahmundry, AndhraPradesh, India

Photos

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)

    


whatever the codes i have posted in past and i will be post in future are my own basic logic's you can also write the code in your own logic in different manner.so if have any doubts u can also contact me personally , you can catch my MAIL ID in about section.and also u can ask me in comment section.
in future i will post different  questions and its codes.so please stay tuned to my blog.  


try:
    a=input()
    x=0
    for i in a:
        if int(i)==1 or int(i)==0:
            x+=1
    if x==len(a):
        z={0:4,1:2,2:1}
        b=[int(i) for i in a]
        d=[[]]
        e=0
        for i in range(len(a)-1,-1,-1):
            d[e].insert(0,b[i])
            if len(d[e])==3 and i!=0:
                d.append([])
                e+=1
        i,c,f,g,h,j=0,0,-1,0,[],0
        while True:
            if len(d[i])!=3:
                d[i].insert(0,0)
            else:
                i+=1
            if i==len(d):
                break
        d.reverse()
        while True:
            while True:
                f+=1
                if d[c][j]==1:
                    g=g+z[f]
                    j+=1
                else:
                    j+=1
                if f==2:
                    c+=1
                    h.append(str(g))
                    g,j=0,0
                    f=-1
                if c==len(d):
                    break
            print(int("".join(h)))
            break
    else:
        print("ERROR")
except:
    print("ERROR")


NOTE: IF YOU HAVE ANY DOUBTS YOU CAN ASK ME IN COMMENTS SECTION.




















         1.write a python program for the above given question.

a=input()
s=0
b={"I":1,"V":5,"X":10,"L":50,"C":100,"D":500,"M":1000}
c=[i for i in a]
if len(c)%2==0:
    for j in range(0,len(c)//2+1,2):
        if b[c[j]]>=b[c[j+1]]:
            s=s+abs(b[c[j]]+b[c[j+1]])
        else:
            s=s+abs(b[c[j]]-b[c[j+1]])
else:
    d=c[0]
    del(c[0])
    for j in range(0,(len(c)//2)+1,2):
        s=s+abs(b[c[j]]-b[c[j+1]])       
    s=s+b[d]
print(s)   
    
NOTE: IF U HAVE ANY DOUBTS YOU CAN  ASK IN COMMENT SECTION.


        

Description

PYTHON PROGRAMMING

Hi.. everyone I'm A.V.R.NAIDU  and i'm also a student, so i know how students get confused in learning how to write the code.Here we go, In this blog i'm going to teach you some basics about python programming for HACKER EARTH programs. So many of the students who want to learn  how to write a python  code for real-time scenario type questions in HACKER EARTH the first thing is to understand the question. Once if you understand the question then 40%  of the code will be completed because in real time scenario type questions understanding the question is main thing.so my suggestion is to understand the question you should read repeatedly until you get the meaning of the question and also you can refer the explanation column which will explains about the sample test cases .second stage is to think the easiest and simplest and efficient logic which will execute all the test cases successfully. we will start with the examples...........