Priyanka
BAN USER
- 0of 0 votes
AnswersImplement an algorithm that takes in a string containing a parenthesized expression and prints it out with all sibling expressions at the same indent level, each on its own line.
- Priyanka in United States
Definitions:
A parenthesized expression consist of an opening parenthesis, one or more expressions separated by one or more spaces, and a closing parenthesis.
An expression is either a word or a parenthesized expression.| Report Duplicate | Flag | PURGE
Snap Inc Software Developer Algorithm - 3of 3 votes
AnswersDesign backend system for bookMyShow.com like system which supports below use cases:
- Priyanka in India
1) When user selects cities, list of cities is displayed.
2) When user selects city, movie list is displayed.
3) When user selects movie, list of theatre is displayed.
4) When user selects theatre, show timing is displayed.
5) When show timing is selected, user is asked for no of seats that he wants to book
6) When user selects no of seats, seats are displayed to choose from.
7) When user selects seats, then total price is displayed.
8) When total price is selected, then user is directed to payment gateway and payment is done and on payment success, ticket is mailed to him.
More questions on how can we scale the system, and handle concurrent users request for same seat etc.| Report Duplicate | Flag | PURGE
Amazon SDE-2 Object Oriented Design - 0of 0 votes
AnswersA file is given which consists of 3 columns : date, city and temperature. For ex:
- Priyanka in India
Date City Temperature
09-11-2015 Delhi 45
09-11-2015 Bangalore 24
09-11-2015 Ranchi 28
and it should support following type of queries:
1) What is the temperature of Bangalore on 9th November?
2) Give 5 hottest/coldest cities name on 9th November
You can preprocess the data and keep it in way that above query can be done in minimal time.
Which data structure will you use and how will you store the data?| Report Duplicate | Flag | PURGE
Snapdeal Senior Software Development Engineer Network
1 Answer Minimize the moves
This is an online written test.
- Priyanka August 26, 2014
Please solve it.
You have a sequence of d[0] , d[1], d[2] , d[3] ,..,d[n]. In each move you are allowed to increase any d[i] by 1 or 2 or 5 i:0 to n .What is the minimum number of moves required to transform the sequence to permutation of [1,2,3,..,n] if it's possible else return -1.
Constraint: 1<=n<=1000
nput:
First Line will have no of elemnts
Second Line on. elements will be present
Ex: 5
1
1
3
2
1
Output:
As no of elements are 5, all permutation can be {1, 2, 3, 4, 5} .
To convert input to get all possible permutation i.e {1, 2, 5, 4, 3},
no of moves will be 4.
Hence output would be 4.| Flag | PURGE
#include<stdio.h>
#include<conio.h>
#define N1 30
#define N2 300
int main()
{
int i, j=0, A[N2],a=0,b=0,flag=0,temp;
for(i=N1;i<N2;i++)
{
temp=i;
while(temp>0)
{
a=temp%10;
if(a-b == 1 || a-b == -1)
flag=1;
else
flag=0 ;
b=a;
temp=temp/10;
}
if(flag==0)
A[j++]=i;
}
for(i=0;i<j;i++)
{
printf("%d ", A[i]);
}
getch();
return 0;
}
Why do we need such complex algo. It can be solved in O(n*m) .Here is the code.
#include<stdio.h>
#include<conio.h>
#define R 6
#define C 8
#define X 2
void printMax(int M[R][C])
{
int i,j,ctr=0;
for(i=0;i<R;i++)
{
int ctr1=1;
for(j=0;j<C;j++)
{
if(M[i][j]==1)
{
if(M[i+1][j+1]==1 && M[i-1][j-1]==1 && M[i+1][j-1]==1 && M[i-1][j+1]==1)
ctr1+= X;
if(ctr<ctr1)
ctr=ctr1;
}
}
}
printf("%d", ctr);
}
int main()
{
int M[R][C]={{0,0,1,0,0,0,0,1},
{0,0,0,1,0,0,1,0},
{0,0,0,0,1,1,0,0},
{0,0,0,0,1,1,0,0},
{0,0,0,1,0,0,1,0},
{0,0,1,0,0,0,0,1}};
printMax(M);
getch();
return 0;
}
RepKimRPierce, Employee at Achieve Internet
I am a customer service-oriented Travel Agent in Travel and Tourism industries. I strongly believe that the skills and abilities ...
Sample input and output:
- Priyanka September 14, 2020Input: (hi)
(
hi
)
Input: (hi hello)
(
hi
hello
)
Input: (hi hello (bye))
(
hi
hello
(
bye
)
)