Académique Documents
Professionnel Documents
Culture Documents
PleaseaddallquestioninthisdocwithheadingCompanyname,CollegeName,Date
2.Pleasegroupquestionsofsamecompanytogether.
3.Pleasetrytoadd
screenshots .F
4.Pleasetrytoaddlinkofquestion(ifpossible)
AllTheBesttoeveryone.
Flipkartquestions???
CodeNationquestions?
Microsoftquestions?//AddedforIITB
SamsungResearchInstitute(Bangalore/Noida/Delhi)questions?
//ADDED
XeroxResearchQuestionsanywhere?
NETAPPQUESTIONS?
SAMSUNGDELHI/NOIDAR&DQUESTIONS?
OperaSolutions??????
TowerResearchQuestionsatIITB?
CISCOQUESTIONS???
uicommerce??
MorganStanleyQuestions?
OlaCabsQuestions?
Operasolution(software)
iitdelhi
timeduration90min
10os(1markeach)
10sql(1markeach)
15c/datastructure(2markeach)
INMOBI
1.5hrtime.
25mcqsand2codingquestions.
MCQs10javaqons,somefromds,memorymanagementandaptitude.
Codingquestions:
Q1.Thereareelectionsintown.Eachcandidatehasbeenvoted.A[1n]isthearray
whereA[i]denotesthethenumberofvotesforthetheithcandidate.ThisarrayA[]is
sortedindescendingorderwithtiesbrokenbyincreasingindices.Youcanincreasethe
votesforanycandidateandalsoyouhaveadesirelistforthecandidate.Rank[1n]
denotestherankofthecandidatethatyouwantthecandidatetobeinthatposition
where1denotesyoudontcareforhim.Findtheminimumnumberofvotesaddedby
youtogettherankofthecandidatesasinRankarray.
^Thequestionisnotclear.
Someonepleasestateitproperly.
Eg.A[]={10,8,6,4,3}
Rank={0,2,1,3,1}
Ans3(Increase6to9)
Eg.A[]={100,40,15,15}
Rank[]={0,1,3,2}
Ans1(tiebreakercase).bner
SolutionApproach..
(Weneedtousethegreedyapproachforthisquestion.makepairsoftheranks
andvotearraytogetherbasedonincreasingranks,andthenformthebackside
checkforanypossiblechangeslikeinfirsttestcase.aftersortingarrayswillbe
(0,10),(1,6),(2,8),(3,4),leavingnegativecase,nowfrombacksideconditionwillbe
falsebetween1,6and2,8soiwillincrease6to9anddone)
Anyreasonwhyfrombackside???
Wecantignore1ranks.Wehavetoconsideritwhenrankarrayislike{1,0,2}
thenwehavetoassignthe1candidaterankequalto1.Ignoringitwillgive
wronganswer.
Q2.Givenndigitnumbersinvector<string>V1<=V.size()<=50.Givenanarrayof
integersofsizeV.size()suchthateacharrayentryhasnumberofhitswithananother
ndigitnumbernum(whichisnotgiveninthevectorV).
wherehitscorrespondstothenumberofcorrespondingsameindexeddigitsmatched
withtheresultantndigitnumber(string)presentinvector<string>V.
findthenumorstateiftherearemultiplesuchnumberspossibleornotpossibleto
predictthenumber.
Singh
thisiswhatiunderstoodbythisquestion..
V=["4231","1322","5741","1234"] (vectorofstringsofsamesize)
N=[0,3,1,1] (comparetheabovevalueswithactual
number(whatweneedtooutput),atV[1]=1322,andactualnumber1342thereare3
digitssameattheirrespectivepositions,sameforV[2],4at3rdpositionismatchedso
theN[2]isequalto1)
nowwearegiventhesetwoarraysandwehavetocheckthatwhetherwecangenerate
thisactualnumberornot..
actualvalueis1342
ANYONEGOTTHESOLUTIONFORTHISPROBLEM?..IFYESTHENPLEASE
SHARE. .:Icouldnotthinkofanelegantsolutionbutanaivesolutioncanbeby
recursion.Fixdigitsatindexandthenrecurseonindex1withtheupdatedhitsarray.
Thoughtheworstcasecomplexitycanbeexponential
Anonymous:Ithinkaboveproblemissimilartothisandsolutionshouldbebruteforce.
http://www.codeabbey.com/index/task_
view/codeguesser
* it checks for each possible code the andrew's answers to the guesses and checks for
all the correct matches and as there is a solution guaranteed to be there and that too
unique one so this approach works.
Feel free to comment and find bugs please and if there is some better approach please
let everybody know ,*/
//acceptedonabovelink:D
#include<iostream>
#include<bits/stdc++.h>
usingnamespacestd
structcombo
{
intcode
intandans
}
vector<combo>guess//toholdtheinputdata
combotemp//toinputthevalues
intclue
voidcompare(intcodecheck,intguessedcode)
{
intc[4],g[4],i=0,j//asonlyfourdigitcode
clue=0
while(codecheck>0)
{
c[i]=codecheck%10
codecheck/=10
i++
}
i=0
while(guessedcode>0)
{
g[i]=guessedcode%10
guessedcode/=10
i++
}
for(i=0i<4i++)
{
if(c[i]==g[i])
clue++
}
}
intmatch(intcodecheck)
{
ints=guess.size(),i,j
for(i=0i<si++)
{
compare(codecheck,guess[i].code)
if(guess[i].andans!=clue)
return0
}
return1
}
intmain(){
intnum,i,j,ans
scanf("%d",&num)
for(i=0i<numi++)
{
scanf("%d%d",&temp.code,&temp.andans)
guess.push_back(temp)
}
//asonly4digitnumber
for(i=1000i<=9999i++)
{
if(match(i))
{
ans=i
}
}
//printf("%d",ans)
cout<<setw(4)<<setfill('0')<<ans
return0
}
INMOBIIITKanpur
1.5Hrpaper
27Questions2codingand25MCQonhackerrank
MCQsoncodesnippets,OS,DBMS,Networks,Aptitude
CodingQuestions:
Howtosolvethis??
Music.YouhaveNsongsinyouriPodandyouwanttocreateplaylistoflengthLwith
repetitions.ButyoucanaddasongagainonlyifatleastKdifferentsongshavebeen
addedafterthesong.
inputN,K,L.1<=N<=100,N<=L<=100,N>K.Outputnumberofplaylistspossible
modulo1000000007.
2.YouhavebeengivenanexpressionX/Y+U/Vasastring,andyouhaveto
evaluatetheexpressionandrepresentitinthesimplestformoffraction.
Eg.3/4+5/4,return2/1asstring.(tostringandstoibothwillworkonhackerrank..andto
concatenatestring/charandinteger,ofstreamwillcomehandy)
Inmobi@IITD
tf1.5Hrpaper
27Questions2codingand25MCQ
MCQQuantandc++codesnippet.2codingquestionsbothonregular
expressionNoos,cnordatastructurequestion.EasyMCQ.
1DetectingValidLatitudeandLongitudePairs link
2
Detectdomainname
link
Bidgely@IITDelhi
6aptitudequestion(moderate)15min
2coding:
1)(Veryeasy):Countthenumberoftimesf(0)andthenumberof
timesf(1)iscalledwhenwerecursivelycomputefibonacci(n).
2)(Moderate)GivenNnumbers,youareallowedtoeitherpairanumber
withanothernumberorleaveitalone.youhavetoMaximizesum(output).
sumisformedbyaddingallunpairednumbersandaddingproductofeach
pair.Ex:n1,n2,n3,n4.Ifyouchoosetopairn1,n2&leavealonen3,n4
thensum=n1*n2+n3+n4
TinyowlIITDelhi
1. MCQIfabinarytreehasKnumberofnodeshavingexactly2children,andL
numberofleaves,thenwhatistherelationbetweenKandL.
2. MCQonperformanceofhashmap.
3.sqlquerytofindthecustomersidforcustomershavingmaximumordersfroman
ordertable
Aselectfoo.Afrom(selectidasA,count(id)asBfrom<giventable>groupbyid)as
foowherefoo.b>=all(selectcount(id)from<giventable>groupbyid)
4.givenastringfindthenextlexicographicallygreaterstring
5.givenanarrayinitialisedto0.therearemqueriesgiventoaddknumbersfrom
indexesatob.findthemaximumnumberfromarrayafterthesemoperations
6.someclassinheritancequestion
7.GivenN,considernumbersfrom1toN.GivenasetSofsomenumbers,letthe
numbersbeS1,S2,S3...Sk.IfIremoveallthemultiplesofS1toSkthatlieinthe
range1toN,howmanynumbersremain?
PFAScreenshots
Citrix@IIT(BHU)
Date10092015
50MCQsincludingbasicaptitudequestions,c2hrtime
++,networking,os,timecomplexity.
2codingquestions:
Q1.ItsPromNighttonight.TherewouldbeMboysandNgirlsatthepromtonight.Each
boywantsagirlwhoisstrictlyshorterthanhim.Agirlcandancewithonlyoneboyand
viceversa.Giventheheightsofalltheboysgirlstellwhetheritispossibleforallboysto
getagirl.
Input:
ThefirstlinecontainsMandN.
ThesecondlinecontainsMintegersandeachdenotingtheheightofboy.
ThethirdcontainsNintegerseachdenotingtheheightofgirl.
Output:
outputallthepairspossibleinincreasingorderofheightofboysandprintYESifall
boysgetagirl.
Q2.giventwostringscheckwhetherfirstisapermutationofsecondstringornot.
EdgeVerve@IIT(Roorkee)
Loc.:Bangalore
CTC:1617LPADate:16thSept
Q1
///howtosolvethis,anysolution???
thebesticanthinkofisrecursionanybetterapproach??
Whatiswrongwiththissolution?
GivenSeriesS
TargetSeriesT
SearchforT[0]inS,sayatindexi.DorotationstillS[i]comesatS[0]andrecurfor
remainingn1elementsofSandT.
Q2Solutionanybody????code
IcanthinkofasolutionKeepanarraytogetindicesofanynumber.
Ifgivensequenceis201,thenarrayb={1,2,0}a[0]=1as0sindexis1
Nowiteratethruthesequence.Foreverynumberi,foralljSTij>=0&&i+j<n,check
whetherijandi+jlieondifferentsidesofthisnumber.Ifyes,wehaveanap.
ButthisisO(n^2)andnis10^4..10^8..DontknowifitacceptsorgetsaTLE.
Q3_1
Q3_2
Isitjust(max(p,1p)/min(p,1p))^n?
>Yes
EdgeVerve@IITMadras
05/10/2015
EdgeVerve@IITDelhi
Date27102015(3questionsonaquestionpaperandcodewasrequiredtosubmitted
viamail)
1. (15marksLongbutsimplequestion)
Question:Givenanexpressionintermsof,+and*,evaluateit.Buteachofthe
terminexpressionismentionedindifferentbase.Soeffectivelyyouhadtoconvertall
theofthenumbersfirstintobase10,evaluatetheexpressionandoutputtheresultina
givenbase.Useanyinbuiltfunctionsyouwant!
2. (10marks)Minimumswapsrequiredtoconvertastringintopalindrome
a. Input:mamad
Output:3
b. Input:aabb
Output:2
c. Input:lsdjfajlj
Output:0
3. (10marks)Givenanintegern,findthelargestpsuchthatforsomeintegera,
suchthatn=a^p
a. Input:64
Output:6
b. Input:128
Output:7
c. Input:729000000
Output:3
PRACTO@IIT(MADRAS)
Date1102015
CTCplz:20
2hrtime
KNOWLARITY@IIT(MADRAS)
C/C++questions:
Date03/10/2015,Time80Mins
CTCPLZ
1)kthSmallestElementinBST
2)Reversealistingroupsofgiven
size.
http://www.geeksforgeeks.org/reversealistingroupsofgivensize/
3)Reverseastackusingrecursion.http://www.geeksforgeeks.org/reverseastackusingrecursion/
4)Circularrightshiftofanumber.GivenanumberofsizeNbits,circularrightshiftbykbits.
5)Removedirtycharacters.
http://www.geeksforgeeks.org/removecharactersfromthefirststringwhicharepresentinthesecondstrin
g/
INMOBI@IIT(MADRAS)
Date5102015
CTCplz:23L(Iguess)
h
25MCQEASY1:30hr
2PROGRAMSEASY
TinyOwl@IITKanpur5thOctober
//Time??
1. GivenadatabaseofEmployees(Id,Name,Salary),youaretowrite
sqlqueryto
reportallthepairofemployeeswherethesalaryoffirstemployeeinthepairishigher
thanthesalaryofthesecondemployee.
2. Giventwoclasses,youarecreateanewclasswhichinheritsthosetwoclasses
andalsoaskedtoimplementafewfunctionsandconstructorforthenewclass.
3. Givenasequenceofcharacters,youaretoprintallthesubsequencesin
lexicographicorder
4. Givenanarrayofintegersreportthemaximumdifferencebetweentwointegers
wherethelargernumberoccursafterthesmallernumber.
5. GivenastringSoflengthn,integerL,K,M.Youaretofindthemostfrequent
substring.Thesubstringshouldsatisfythefollowingcriteria:
a. lengthofstringshouldliegreaterthanorequaltoLandlessthanorequal
toK
b. thenumberofdistinctcharactersinthesubstringshouldbelessthanM
SPRINKLRIITKanpur
4questions,2hours
1. https://www
.hackerrank.com/contests/testcontest27/challenges/histogram
2. https://www.hackerrank.com/challenges/legoblocks
3. https://www.hackerrank.com/challenges/lexicographicsteps
4. Wehavebeengivensomepairs,{A,B},{A,C},{B,D}...
where{p,q}=>pisparentofq.Wehavetoprintstring
representationoftreewhichisgeneratedfromthesepairs.
giventwostringscheckwhetherfirstisapermutationofsecondstringor
not.Example:{A,B},{D,C},{B,D},{A,E},{E,F},{E,G}
Ans:(A(B(D(C)))(E(F)(G)))
Incaseoffollowingerrors,showerrorcodeofhigherprecedence.
E1morethan2children
E2duplicateedges
E3multipleroots
E4cyclepresent
E5anyothererror
SPRINKLRIITDelhi
20MCQquestions,25minutes
Questionswerebasedonoperatingsystemconcepts(spinlocks,
mutex,preemptivekernel,etc),DBMS,Networks,Sharding
3codingquestions,2hours
1. FindnumberofWaterBodiesoveramassoflandmassoflandis
representedbyagraph.Graphisfilledwith0and1which
representlandandwaterrespectively.Allthe1sconnectedby
8connectivityproblemrepresentasinglecontinuouswaterbody.
Outputthetotalnumberofwaterbodies.
Examplefollowinggraphhas2waterbodies
0100
1000
1000
0010
1. AnotherquestionwasbasedonDijsktrasalgorithm.Itwasabig
questionbutessentiallyitwasshortestpathalgorithm.
2. GivenNintervalsona1Dline(eg(1,6)(4,7)(10,11)(12,25)
(20,24)).Eachintervalisgivenavalue(eg3,4,10,6,5respectivelyfor
previousintervals).Findthemaximumvaluethatyoucanachieveat
anypointontheline(egmaxvalueis11at(20,24)).
QualcommIITK08102015
AllpartsareMCQ
Important
1. Therewasnegativemarkinginallthesections(+1,0.25).
2. Timeforeachsection.Ifyoudonotcompleteasectioninthegiventime,youwill
beautomaticallydirectedtothenextsection.
Aptitude20minutes(riverboat(1),percentage,fraction,twoDataInterpretation(6),
probabilityandothers(remaining))total20
C(gettherecursionvalue,functionscalls,readaboutenums,functionoverloading,qu
abtconstkeyword,MACROS,etc,structandunion,whichalgouseswhatsubroutines
(likeDijkstrausesqueue)minnoofnodesinanAVLtreeofheight3 (solution?)
const,mutable,autokeyword)
FindtheoutputquestionsinCbasedonextern,externwithstaticandregister
declaration,enum,union,rightshiftoperator(>>),operatorprecedence,onequestionon
#undefandonemorequestionon#ifaswell.
electronicstimer555,shiftregister,8051,effectofdopingonfermilevel(impuritywas
boron)feedbackcircuitinopampsnumbersystem,Gettingstateequationsfor2Dflip
flopsfroma4stateFSMwith1inputand1output,1simplequeonSRflipflop,a
complicatedTTLlogiccircuitwasgivenandwewereaskedwhichgateitrepresents,1
queonreducingalogictosumofproducts,1rectifiercircuit(askedthecorrect
waveformofoutput)
(mentionedthetopicsdontremembertheexactquestionsreadtillcertaindepth)
(overallwasrathertoughgiventheverylimitedtime,mostpeopleattemptedonlyabout
halfofthequestions.samestoryforCS)
f
ComputerScience(20MCQ30minutestime)CSCANdiskschedulingalgo,
Bankersalgo,binarysearch,recurrencerelationofbogosortwithgivenpartition,noof
pagefaultsinLRUwithframesize6,noofswapsinmergesort,fork,thispointer,
inordertraversalofacompletebinarytree,strictbinarytree.
Paypal@IITK11102015
CTC25L
Aptitudequestions45mins
1Codingquestion30min
Q)Findthelengthofthelongestpalindromeinastring.//substringorsub
sequence?(itssubstring)
O(N^3)solutiongotaccepted.
CanyoupleasementionaptitudetopicsPayPalcovered??
TopicsinaptitudewereTimeandSpeed,Direction,DI,arrangements,P&C,coding
Decoding(Total20questions=15apti+5Technical)
aptiquestionswere1markeachwhiletechnical3markswith0.25negativeforeach
wronganswer.Codingquestionwasof50marks.
P.S.incaseyourestuckintakinginputintheformofstringsineachlinejustdo
while(cin>>s)wheresisyourstring.(coolbey)
//TechnicalMCQs??
//Yes,CananybodytellthetechnicalMCQsasked?Itwouldbeagreathelp!!
OStheoreticalquestions,somecoutputquestions
Paypal@IITR20102015
sameasiitkseriously!!wow!
Paypal@IITM20102015
sameasiitkseriously!!youhavegottobekiddingme!
Paypal@IITD26102015
sameasiitkseriously!!Paypalisawesome!:P0
Thisisjustsad!:(
Paypal@IITBHU29102015
CTC25L
Aptitudequestions45mins
1Codingquestion30min
Q)Amanhasabucketwithahole.HecanwalkmMileswith2litofwater.Hecanrefill
thethebucketatastation.Hehastocrossnstations.Givendistanceofeachstation
fromstartingpoint,findtheminimumstopshehastotaketocrossthestations.
inputoutput
(1,3,6,9,13,16,18,19),56
Adobe@IITBHU11102015
Platform:Hackerrank,90mins
1.GiventwoStringsSandP,wherePcontains'a''z'lettersinsomeorderand|P|=26.
Findthesmallestlexicographicpermutationof,Saccordingtotheorderofalphabetsin
P.
//Canyouelaboratemorethisproblem??
//thisisthesameassortingSaccordingtotheorderdefinedinP,right?
//oramImissingsomething
YESITISSAME .
2.https://www.hackerrank.com/challenges/clique
//canyouprovidelimitsforthisquestion?ImeanwasBrutesolutionacceptable?
//ifnot,howtosolvethisproblem
3.ThereareNstudents,eachhavingalistoffavouritesubjects.Youhavetofindtotal
no.ofpairsofstudentsthatcanhelpeachother.Twostudentscanhelpeachotherif
theyhaveacommonsubject.
InputFormat:
Firstlinecontainstheno.ofstudents,N.
NextNlineseachhasanumberofthefavouritesubjectsfollowedbythelistofsubjects.
Ex.
3
3dfsbfsgraph
1flow
2flowgraph
Output:
2
N,Totalno.ofsubjects(K)<=1000
BruteForcewasnotacceptable
UsedMaptogiveeachsubjectanindexandthenabooleanmatrixofsizeNXK.
Tofindanswerpickeverypairof
studentandthencheckwhetherthispairhasacommonsubject,O(N^2*K)got
accepted.
PickingupapairandcomparingtheircommonsubjectswilltakeO( K
),right?
TherearesuchN^2pairsthenhowcomeyoursolutionisO(N^2*K)?
?aintthisabovesolutionbruteforce?
HadabooleanmatrixofsizeNXK,sayarrwherearr[i][j]=1denotesthatithstudent
hasjthsubjectasitsfavourite.Nowforeverypairofstudentsays1ands2,iterateover
columnandseeifarr[s1][x]==1&&arr[s2][x]==1forany1<=x<=K.
Ifthishappensthencounts1ands2apair.HenceO(N^2*K)
IdontknowwhatyouimplywithbruteforcebutsomeofuswerehavingaTimeLimit
Exceeded,butabovesolutiongotaccepted.
Oronecouldhaveaftercomputingthearray,computeforeachcolumn,thenumberof
bitssetandthencomputeNC2
(Whatwasthetimeofthistest??)
No,computingNC2foreachcolumnmayleadtorepetitionofpairs(Onepaircanhave
morethanonecommonsubject).
Nutanix@IITK12102015
Q.1Inanarray1tonnumbersarepresentinsomepermutation(P[1...n]).Youcan
representeachpermutationbyasignature.Signatureconsistsofletters,iandd.If
P[i]<P[i+1]thenS[i]=ielseS[i]=d.Nowfromagivensignature,identifythe
lexicographicsmallestpermutation.Lengthofpermutationisnandlengthofsignatureis
n1.
https://learn.hackerearth.com/fon.Mostsorethroatsarecausedby
rum/182/lexicographicallysmallestpermutationgivenasignature/
eg.
ii>1,2,3
di>2,1,3
dddddi>6,5,4,3,2,1,7
l
Q.2Findtheminimumjumpsrequiredtoreachfrom(0,0)to(n1,m1)ofagrid.grid[i][j]
containsthenumberofblocksyoucanjumpfrom(i,j)ineitherrightordowndirection.
Itsispossiblethatthereexistsnopathtothedestination.Print0inthatcase.
eg.
33
212
421
111
output
2
thereare2pathsfrom0,0to2,2
0,0>0,2>2,2
0,0>2,0>2,1>2,2
minimumis3//
Inthiscaseminimumshouldbe2becausewehavegoneonly
in2blockscansomebodyexplainquesproperly
2,4
1234
2123
output
0
nopathexists
0,0>0,1>0,3
0,0>0,1
0,0>1,0>1,2
Nutanix@IITDelhi
Date13102015
2codingquestions70minutes
1. givenarrayofnonnegativeintegersandatargetinteger,findthenumberof
waysyoucanmakethetargetintegerusingalltheintegersfromthearrayandin
thesamesequence.youareonlyallowedtouse+oroperatorbetweentwo
elements
Howtosolvethis??
##whatweretheconstraintsforthisquestion?,sometest
casesatleast?
Input:
Array:121
Sum:2
Output:
2
Explanation:
1+2+1=2
+1+21=2
So,thereare2waystobringsumas2byadding/subtractingallthe
elementsfrom{1,2,1}
2. givenanarray0123findminnumberofwaystoconvertitinto1023.Allowed
operationsare,youcanonlyswapanelementwiththe0element.
Questionnotclear.Someonepleaserestate
NUTANIX@IITGuwahati
Date05/10/15
60minonhackerrank
Q.1GivenArrayofNintegersandQqueries(pair(i,j)suchthat1<=i<j<=n)give
minimumvaluebetweenindexiandj(iandjincluded).Youhavealsogivenintegerk
suchthatk<=ji+1<=2*k.Indexingwillbe1based.
INPUTFormat:
NKQ
A1...AN
i1j1
.
.
iQjQ
eg.
Input
623
421653
13
25
46
Output
1
1
3
##whatiskinthissampletestcase?canyouelabourateit?
Willsegmenttreework?[segmenttreeorbruteforcebothwillwork]
Q.2characters(eaGivenastring(allcharactersareaz),youhavetoremoverepeated
chcharactercanoccuronlyonce)whilepreservingordering.Resultedstringshouldbe
lexicographicallysmallest.
eg.
Input:
abcbc
jsabj
jsabjs
Output:
abc
jsab
abjs
Solution:UseStack(
http://www.careercup.com/question?id=5758790009880576 )
Solution:simplehashingusingarray.complexityO(n)
#include<iostream>
#include<cstring>
usingnamespacestd
intmain()
{
charstr[100],res[100]
intcount[26]={0},j=0
cin>>str
for(inti=0i<strlen(str)i++)
{
count[str[i]'a']++
}
for(inti=0i<strlen(str)i++)
{
if(count[str[i]'a']>0)
{
if(count[str[i]'a']==1)
{
res[j++]=str[i]
count[str[i]'a']=0
}
elseif(i<strlen(str)&&str[i]<str[i+1])
{
count[str[i]'a']=0
res[j++]=str[i]
}
else
{
count[str[i]'a']
}
}
}
res[j++]='\0'
cout<<res<<"\n"
}
Abovecodewontworkforallcases.Only6/9testcaseswerepassing.Stacksolutionis
correct.
INMOBI@(IITGuwahati)
Hackerrankplatform.90mintest.
1. KthOptimalpathinamatrix.
(
http://programmers.stackexchange.com/questions/260972/kthoptimalpathina
matrix )
Youcansolveithereonhackerearth:
https://www.hackerearth.com/problem/algorithm/kthshortestpath/
Solution:useDP.Testcasesweretoostrict.
2. Givenanarrayofintegers,youneedtocheckifitsanarithmeticprogression,
geometricprogressionorfibonacciseries.Youthenneedtoreturnthenext
numberintheseriesor999ifthegivennumbersdoesnotfollowanyofthe
aboveseries.Thefibonacciseriesneednotstartwith0.Avalidfibonacciseries
couldbe8,9,17
CARWALE@IITGUWAHATI13102015
CTC:17lpa
Therewere4problemsand2hoursoftime.Platformwashackerrank.Theproblems
weretakenfromcodechefasitissoImpostingthelinkoftheoriginalquestions:
https://www.codechef.com/problems/CSUMD
https://www.codechef.com/problems/LINEPROB
https://www.codechef.com/problems/LWS
https://www.codechef.com/problems/EQUATIO
ADOBE@IITGUWAHATI15102015.
Therewerethreecodingquestions(3questionsin60mins):
https://www.hackerrank.com/challenges/sansaandxor
https://www.hackerrank.com/challenges/flowers
https://www.hackerrank.com/challenges/twostrings
Wehadadiscussionwiththecompanyguyafterthetestandtheysaid,wehaveset
easyquestionthistimetocheckwhetherpeoplewillbeabletodothoseornot.(actually
insomeNITtheygavehardquestionsandnobodywasabletocomplete).Soquestions
willbehard/moderatenexttimebut90%fromhackerrank.
WalmartLabs@IITRoorkeewalmart
16102015(90min)
CTC:19
//Wherearethequestions???PleaseUpdate!!!
Thesolutionstoquestionshavebeensubmitted.Dontworry,nextyearduringthe
paper,thequestionwillcomebackagain.
Averysimpleprobabilityquer1/xestion.Answ(youllknowxwhenyou
seethequestion)butmanyfacedproblembecausetheydidntknowhowto
setprecision10.Usefixedsetprecision.
http://www.geeksforgeeks.org/findnumberofislands/
http://stackoverflow.com/questions/3947867/findtheleastnumberofcoins
frequiredthatcanmakeanychangefrom1to99ce
WalmartLabs@IITK
10mcqs(1markeach)and3codingquestions(100markseach)in1.5hours(butI
heardthereareindividualcutoffsforbothsections)
Givenamathematicalexpression,checkwhethertheparenthesisusedinthat
expressionarebalancedornot.Possibleparenthesisusedcanbe{},[],()
only.Eg.(2+3)/4*[9+{8*5}].
mcqsmostlyonOSanddatastructuresthreadproperties,implementationof
queueusing2stacks,propertyofassemblycode,doublepointerdeclaration,
expectednumberoftrianglesingraphwith8verticeswithprobofedgeexisting=
0.5,DefinitionofP,NPcompleteandNPhardetc.
Codingquestions:
1) http://stackoverflow.com/questions/29376069/lexographicallysmallestpathina
nmgrid (thoughthedivideandconq.methodismoreelegantandeasierto
code)
Supposethegridisnxm.Findminofmatrix.Supposeitis(i,j)thelement.Nowthe
remainingpathcanonlybeinmatrix1ofsize(ixj)(lefttopma
rixofi,jthelement)andmatrix2ofsize(ni,mj)(bottomrightmatrixofi,jthelement).
Recurforthem.
ortheexactquestionis: http://www.careercup.com/question?id=5149445358354432
arrayelementsarecharornumbers?ifnumbersthenwhatismeantbylexicographic
order??Ifelementsare9,10then{9,10}issmallerthan{10,9}butifwehavetoform
numberthen109issmallerthan910.Pleaseexplain..
2) http://www.geeksforgeeks.org/findthelargestrectangleof1swithswappingofc
olumnsallowed/ (slightmodification:wealsohadtooutputtheminimumnumber
ofswapstoachievethelargestarea)
3) Define,f(x)=gcd(1,x)+gcd(2,x)+....+gcd(x,x)
Input:
a[],multiplepairsof(i,j)(i<=j)(oftheformCij)output:
f(a[i])+f(a[i+1])+..+f(a[j])foreachcase
Therewasalsosomethingaboutupdationofthearraya[](testcaseoftheformUij)
butIdontremember.
Infosys(17LPA)@IITRoorkee
17102015(90min).
2codingquestionsonhackerrank
1)Giventwoarraysofnumberofstocksandtheirprices,outputtheminimumsumof
productoftermsofthesetwoarrays.
Questionisverysimple.Themainproblemmostguysfacedwastoconvertstringtoint
andviceversabecausetheinputwasgiveninstring 23#456where123
1
representsthefirstarrayand456thesecondone.thestringwaspassedtoafunction
andwewereallowedtomakechangesonlyinthatfunction,
2)ThereareNemployeesittinginconsecutivecubicles,wehavetosendafewofthem
toonsite,buteachtimewesendoneemployeeonsite,hiscubiclebecomesempty,
nowtheotheremployeesfrombothsideofthatemptycubiclestopsworkinguntilthey
aregivenagift.
thegiftsaregiveninbothsidesoftheemptycubicleuntilwereachtheendorfound
another emptycubicle,
Inputnumberofcubicle,andindexnumbersofpeopletobesent
outputminnumberofgiftsneeded
Cansomeonebetterexplainthequestion?Whatdoyoume
anbyuntilwereachendorfoundothercubicle?Thereisalwaysanothercubicle
otherthanatends!!
empty
Its cubicle.Ihaveeditedthequestion.Ithinkyourdoubtmusthave
clearednow.
Hint:wehavetofindtheorderinwhichwewillsentthepeopleonsite,findtheindex
thatsinthemiddleornearaboutmiddleandsendhimout,keepdoingthesameforleft
andrightsubarray,therearemanyotherwaysofdoingthisbyusingbinarytrees.
Forboththequestions,inputandoutputwereinstringformat.
Coupondunia@IIT(BHU).
3questions90minutes
CTCPlz=
16.5LPA
1.Santacandy
Givennchildren.Santawantstogivecandytoallchildrensuchthatallchildrenget
distinctnumberofcandy.Alsoithchildcanholdonlymax[i]candy.Findnumberofways
santacandistributecandy.mod=1000000007
sol:Firstsort!Thenfor(i=0:n){ans=(ans*(max[i]i))%mod}
initial:ans=1
firstchildrencangetcandyinmax[0]ways,2ndin(max[1]1),3rdinmax[2]2waysand
soon.
Couldyoupleaseexplainthis.Alsowhatisvalofansinitially
2.Asetofstudentsx1,x2,x3,.....xn<10^9.Findthesetx1,x2,x3,.....xrwhichhave
maximumscored.Ascoredismaximumif(x1&x2&....&xr)modulus2^diszero.Return
thesetofstudentswhichhavemaxvalueofd.
Shouldthevaluesbeaprefixofgivenset?Asinx1,x2,x3..canthevaluesbeany
rxs?Andwhatiftherearemanysuchsets?
Yes,canbeanyrvalues(r<=n).Iftherearemanysuchsetsgivesetwith
maximumnumberofvalues.
3.Racetrack
Givennracetracks,time[i],timetocompleteithtrack.rest[i],timetorelaxbefore
runningonothertrackjafteritrack.relaxtime=|rest(j)rest(i)|relaxtimebeforegoing
fromithtracktojthtrack.GivenTimeT.findmaxnumberoftrackthatcanbe
completed.
O(T*n*n)Isthisalgook?Whatarethelimits?
Inthequestion,n<=12,sobruteforcesolutionwillwork.
12!is10^9Wontwork.Doyoumeansomethingelsebybruteforce?
Oracle(AllProfiles)@IITRoorkee
18102015(120min)[ ]
sameinIITGuwahati.
Thequestionpaperconsistedofonlymultiplechoicequestions.Paperwasdividedinto
4parts
a. ComputerScienceMostlyquestionsfromDS,SQL,OS,DBMS,predictthe
outputetc.
b. SoftwareAptitudeQuestionsonFlowchartanalysis,CodeAnalysis
c. AptitudeQuantitative,DataInterpretation,LogicalReasoning
d. CommunicationReading,Writing,Grammaretc.
AllhadalmostequalweightagealthoughSoftwareaptitudehadthehighestamong
these.Numberofquestionswerelargeforthegiventime.
HikariTsushin@IITRoorkee
23102015(75min)
Threesectionwithmultiplechoicequestion6+
Quantitativeaptitude20questions
LogicalReasoning25questions
CodingCoutput/DataStructures30questions
Veryeasypaper.
Citi@IITRoorkee
24102015(125min)
ThreesectionswithmultiplechoicequestionsAlso,itsmentionedthatthetestis
adaptive
Quantitativeaptitude16questions16min
LogicalReasoning14questions16min.
CS25questions(MostlyDS/COutput)35min
Coding2questions.60min.(differentsetforeveryone)
(thequestionsweredifferentfordiff.individuals)
1. Math(checkforconsecutivegreycodeterms)
2. Findminimumsumpathfromroottoleaf
3. findmatrixmultiplicationwithitstranspose..
//Pleaseelaborate
Youaregivenavaluekanddimensionsmxn.Thefirsttermofthematrixisk
thenitisk+1...soon(rowbyrow)untilthematrixfills.Nowmultiplythismatrix
withitstransposeandreturntheresultantmatrix
4. findifagivenbinarytreeissubtreeofanothergivenbinarytree.
5. Reversethelatterhalfpartofagivenlinkedlist.
6. Printnumbersinagivenfashion
givenn=4
1*2*3*4
9*10*11*12
13*14*15*16
5*6*7*8
givenn=5
1*2*3*4*5
11*12*13*14*15
21*22*23*24*25
16*.....................*20
6*7*8*9*10
(IHAVEMODIFIEDTHEPATTERN)..yesitiscorrect.
7. findgcdofgivennnumbers
8. Givenamxngridconsistingof0and1where0denoteswalland1denotesthe
movablepath.Gridalsoconsistsofnumber9atonecoordinatewhichdenotes
locationofcheese.Aratstartsatposition(0,0)inthegrid,weshouldcheck
whethertheratcantraveltocheese(inotherwords9)followingonly1s.
9. Givenarray={1,1,3,3,3,2,5,5,5,5,5,9,9},weshouldarrangetheminthe
decreasingorderoffrequencyandtheelementswithsamefrequencyshould
comeintheordersameasinthegivenarray.Sotheexpectedoutputarrayis
{5,5,5,5,5,3,3,3,1,1,9,9,2}
//Douguysrememberwhatalltopicswerecoveredinmcq.??
(tofinderrorsinloop(mostlyvariablesnotinitialized),classes,encapsulation,
stablesortingtype,selectionsort,functions,bubblesort,minimumnumberof
stackstomakequeue)Themcqswereverysimple
Citi@IITDelhi
25102015(125min)
SameasIITR.
//Douguysrememberwhatalltopicswerecoveredinmcq.??
Citi@IITBHU27102015(125min)
SameasIITR.
Citi@IITBombay
31102015(125min)
SameasIITR.
Citi@IITM29102015(125min)
samequestionsasIITR.
GROFERS@IITDELHI,IITJODHPUR,IITHYD
3questions.3hoursonCodeChef.
Q1.EncryptionAlgorithm
Problemdescription.
Wehavesometextualdocumentsthatweneedtoread,butthedocumentsare
encryptedandweneedtodecryptthem,giventhekey.`
Wecallthecontentoftheencryptedsentence,the"ciphertext".Wecallthecontentof
thedecryptedsentencewhichisthesameascontentthatwasoriginallyencryptedby
ourencryptionalgorithmthe"plaintext".
Fortunately,allthedocumentsthatwe'veencrypted(alltheplaintexts)areofasimple
form:wordsseparatedbyspaces,commas,andperiodsthewordsaremadeuponlyof
ASCIIletters.
Theencryptionalgorithmistrivial.Foragivenplaintext,andagivenencryptionkey
(whichisawordasdefinedabove),thealgorithmproducesaciphertext.Theciphertext
isthesamelengthastheplaintext.
Ifaplaintextcharacteris*not*aletter,thenthecorrespondingciphertextcharacteris
thesameastheplaintextcharacter.
Ifaplaintextcharacter*is*aletter,thenthatplaintextcharacterispartofaplaintext
word.Thecharactersofaplaintextwordareencryptedbyapplyingafunction
("encryptionfunction")totheplaintextword.
Todefinetheencryptionfunction,wefirstdefinesomethingcalledthe"encryptionpad".
Theencryptionpadisaninfinitesequenceofcharactersproducedbyconcatenatingthe
keytoitselfinfinitelymanytimes.Forexample,ifthekeywere"Wow",thenthe
encryptionpadwouldbe"WowWowWowWow...".
Foreachplaintextcharacteroftheplaintextwordsay,theN'thcharacterweselect
acharacter("padcharacter")fromtheencryptionpadthatisatthesameoffset(i.e.,the
N'thcharacterfromtheencryptionpad).So,forexample,iftheplaintextwordwere
"Super",andthekeywere"Wow",then,fortheplaintextcharacter,'e',wewouldselect
thepadcharacter,'W'.Thentheciphertextcharacterisdeterminedfromtheplaintext
characterandthepadcharacterasfollows:
Forapadcharacterof'a'or'A',theciphertextcharacterisequaltotheplaintext
character(i.e.,thecharacterisunchanged).Forapadcharacterof'b'or'B':'a'becomes
'b''b'becomes'c'...'z'becomes'a'(andsimilarlyforuppercaseletters:'A'becomes'B',
etc.)Forapadcharacterof'c'or'C':'a'becomes'c''b'becomes'd'...'z'becomes'b'
(andsimilarlyforuppercaseletters:'A'becomes'C',etc.)Andsoonforotherpad
characters.Yourjobistowriteacompleteprogramtohelpwiththis
Input
Inputdescription.
Thefirstlineoftheinputwillbeanylineofciphertextandsecondlinewillbethe
keyofencryptionalgorithm
Output
Outputdescription.
Yourprogramshoulddecryptthesentenceandoutputthedecryptedsentenceto
standardoutput.Theprogramshouldproducenootheroutput..
Example
Input:
Cvlikok
Grofers
Output:
Wegetit
Explanation
TheveryfirstletterofplaintextwascapitalWwhenweencryptitwithkey
GrofersthenitbecameC,samealgorithmwhenyouwillapplyforalllettersyou
willgetciphertext
Q2.Toloadornottoload
Problemdescription.
Duetorapidexpansion,Groferswantstobuildalargedistributedstoragesystemon
theweb.Millionsofuserswillstoreterabytesofdataonitsservers.
Onewaytodesignsuchalargesystemwouldbetohasheachusersloginid,partition
thehashrangesintoequalsizedbuckets,andstorethedataforeachbucketofusers
onasingleserver
Forthisscheme,mappingausertoaserverisasimplehashcomputation.
However,ifasmallnumberofusersoccupyalargefractionofthestoragespace,
hashingwillnotachieveabalancedpartition.Onewaytosolvethisproblemistomake
thehashbucketshavenonuniformwidthbasedontheloadinthathashrange.
Youhavenusersandmservers.
UserirequiresB(i)unitsofstoragespace.
YoudesignastrategywhichfindsnumbersK(1)throughK(m)suchthatallusers
betweenK(j)andK(j+1)getassignedtoserverj.
Yourstrategyminimizestheloadonthe
mostheavilyloadedserver.GiventhearrayB,numberofserversmandnumber
ofusersn,
yourprogramshouldoutputtheLoadonthemostheavilyloaded
server.
Input
Thefirstlineofinputistwointegervalue,thetotalnumberofUserN,totalnumberof
ServerMandthesecondlinehasspaceseparatedintegerswhicharetheuserstorage
requirements.
Output
Outputsinglelines,theloadonthemostheavilyloadedserver
Constraints
1 N
100000
1 M
100000
Example
Input:
52
23151
Output:
6
Explanation
[23151]
sostartingthreeuserwillbeservedbyfirstsystemandlastthreeuserwillbe
servedbylastserver.
Q3. WarehouseManagement
Grofershaslargewarehouseswhereeachwarehouseismanagedbyasinglerobot
namedGoJwala.
GoJwala'sjobistoreceivetheorderandpickupthecorrespondingorderitemfromthe
warehouseshelfanddroptheitemintoadeliverybox.
EachwarehouserecievesNordersdaily.Eachorderisdefinedbythefollowing:
1)UniqueorderId
2)Orderreceivedtime
3)Numberofitemsrecievedinthisorder.
4)Deadlinetopackthisorder.
5)LossincurredbyGrofersincasetheabovedeadlineisnotmet.
GoJwalaneedstopickupandplacetheseitemsinthedeliveryboxbeforethe
deadlineforthisorderisreached.IncaseGoJwalacannotpacktheorderwithinthe
deadline,Grofers
incursalossperiteminthatorder.YouneedtoprogramGoJwalatopackeachitemin
theorderbeforethedeadlineis
reachedminimizingthelossincurredbyGrofers.Theprogramshouldprovidethe
minimumamountoflossincurredbyGrofers.
PleasenotethatGoJwalacanpickupatmostoneitemfromthewarehouseshelfata
unittimeandthis
pickupanddroptakesexactlyoneunittime.GoJwalacanstartnextjobassoonasthe
first
itemisdropped.Asaresult,youcanignorethetimeittakestherobottogofromdropto
pickup
locationinthewarehouse.Therobotcanpickupattheitemsatanytimebetweenthe
orderreceivedtime
(inclusive)andthebeforethedeliverytime(notinclusive).GoJwalacannotpickany
itemsfromaorder
exactlyatitsdeadlinetime.
Input
Input:
TNumberofTestCases
NNumberoforders
Foreachorder,wehavethefollowingordercharacteristics:
1)orderId:Uniqueorderidentifieraninteger
2)receiveTime:Anintegerdenotingaunitintime
3)numItems:Numberofitemsinthisorderaninteger
4)packingDeadline:Deadlinetopackthisorderaninteger
5)loss:Lossincurredifthisorderisnotpackedwithinaparticulartimeframean
integer
Note:TheinputwillguaranteetohavereceiveTime+numItems<=packingDeadline
output
TheoutputcontaintheminimumamountoflossincurredbyGrofers.
Example
Input
1
2
115610
215610
Output
50
Explanation
Thereisonlyonetestcase.andGojwalahasonlytwoorderswithorderids1and2,
recievetimeoforderid1is1,numberofiteminthisorderis5andpackingdeadlineis6
soallItemofthisordercanbepackedinthedeliverybox=1x5=5unittime
recievetime=1
totaltime1+5=6.
AllthetimeGojwalawaistedonorderid1soGoJwalaisnotabletopackedasingle
itemoforderid2,henceforththelossonsecondorderis10x5=50sototalloss=50
YodleeInfotechprivateLimited@IITB
Date:25/10/2015
Package16.61LPA(Gross)
AssessmenttakenbyFirstNaukri
ExamPattern
4sections1)GeneralAptitude20questions(25mins)
2)TechnicalAptitude10questions(10mins){ }
C,C++,Java,SQL,OS
3)CodeSnippetOutputs10questions(20mins)
4)Programming1question(25mins)
Program ThereareMtestcases.Foreverytestcaseyouaregivenanintegeri.Find
outasmallestpositiveintegersuchthattheirmultiplication(i*j)isanumbercontaining
only4sfollowedby0s.(Pattern4+0*).IfPisnumberof4sandQisnumberof0s
thenforeachi,output2*P+Q
Eg.Input
2
Numberoftestcases
5
9
Output
3
18
Explanation 5*8=40>P=1,Q=1>Output=2*1+1=3
9*49382716=444444444>P=9,Q=0Output=2*9=18
Howtodothis?
AnyIdeaisWelcomed
Solution:
http://ideone.com/EuX4d3
SamsungResearchBangalore@IITB
Singlecodingquestion:Givenn*nmatrix(n<=100),wheresomecellswillhavemirrors
ofoneoftwotypes.Type1:/andType2:\.Thesemirrorswillreflectlightby90
degree.Asinglerayoflightentersat(0,0).Youhavetofindoutthecountofthenumber
ofreflectionsonmirrorsbeforetherayleavesthegrid.
Solution:storecurrentdirection(4directionspossible).Ifcurrentcellhasmirror,update
directioncorrespondinglyandincreasereflectioncount.Alsokeepupdatingx,y
coordinatesgivendirection.Whencurrentcoordinatesreachoutofgridprintthecount.
G.S@IITK//(GoldmanSachs)
Objective:3sections:CS,QuantandDataScience,eachhad10questions(+3,1)
Time:?90min.
CS:regularexpressions,nutsandboltsproblem(2questions),1quedescribed4
graphsintermsofno.ofvertices,edgesandconnectedcomponentcodes.wehadto
choosethegraphwhichwasfeasible,whatdoes(i,j)thelementofnthpowerof
adjacencymatrixrepresent( ifAisannxnmatrixandB=Athentheentriesb ofB
i,j
areobtainedas
.
Thereforeb =1ifandonlyifthereisavertexkwitha
i,j =1anda
i,k =1.Wellthisisthe
k,j
sameassayingthatthereisapathoflength2fromvertexitovertexj.Sowecan
concludethatb isthenumberofpathsoflength2fromitoj.(Ifi=jthenyoujustget
i,j
thedegreeofthevertex) )?,ishttppersistent/nonpersistent/both
Quant:
1)bayestheoremsimpleapplication
2)sidesofrectanglechosenindependentlyfromuniformdistribution.Whatisprobability
thatareaofrectangleisgreaterthan0.5?(ans.(1ln2)/2)
explainpls??ifthesidesarexandy,doubleintegralof1*dy*dxasyvariesbetween
*xand1andxvariesfromto1.(orviceversa)
3)trace(A)=4,trace(A*A)=16,det(A)=27,trace(A*A*A)=?(ans:145) //Whetherthis
answeriscorrect?Answerisindeed145!!
ans=4*16+3*27=145aftersolvingthethreeequations
a+b+c=4
a^2+b^2+c^2=16
a*b*c=27
//
Ithinktheanswershouldbe145bythefollowingmethod
howisit91??explainpls!//Ithinkwecandoitasbelow
trace(A)=sumofeigenvaluesofA=4
l1+l2+l3=4
trace(A*A)=sumofeigenvaluesofA*A=16
l1*l1+l2*l2+l3*l3=16
det(A)=27=>l1*l2*l3=27fromthesethreeequation,findl1^3+l2^3+l3^3
Doubt:WasthedimensionofthesquarematrixAgiveninthequestion?
Yes3x3
4)f=A*sin(x)+B*cos(x)isavectorspace.L=f+fwithbasis{sinx,cosx}.Matrix
representationofL?(ans:[1111])
cansomeoneexplainhow?// basiclinearalgebraproblem
Everylinearfunctionhasacorrespondingmatrixrepresentation.Anyfunctionwithbasis
(phi1,ph2etc.)canbewrittenasf=A1*phi1+A2*phi2+...Here,L(f)=(AB)sinx+
(A+B)cosx.SoLtransforms(A,B)to(AB,A+B).Sodoesthematrix[1111]because
[1111]*[AB]=[ABA+B].Hencethatmatrixisrepresentsthegivenfunction.
5)howmanyintegersxarethere,suchthatx^23*x19isdivisibleby289?(ans:0)
6)largestareaoftrapezoidinsemicircleofradius2withdiameterasoneside?(ans:
3*root(3))
7),8),9),10)werequitelong
DataScience :1)howdoesadaboostimproveclassifieraccuracy?
2)youhave10000faircoins.P(gettingmorethan5100heads)? //Ansusingnormal
approximation.
3)onequestiononhypothesistesting(nothingtosolve,remembertheterms)
4)somequestionsondetailsofNearestneighbour,SVM,naivebayesandother
classifiers
Quant:
1)P(head)=p,expectedno.oftossestogetfirst2consecutiveheads?(ans:
(1+p)/p^2)how???// shouldnttheansbe{(1+p)/p^21}nope//plzexplain
https://www.quora.com/Whatistheexpectednumberofcoinflipsuntilyougettwohea
dsinarow //Thankswasmissing2*p^2
nCarswithvelocitiesinarandompermutationareleavingaplace.Asafastercar
approachesaslowercaraheadofitself,thetwocarsstartmovingatslowercars
speed,formingagroup.Groupskeepmergingthiswayalonganinfiniteroad.Expected
no.ofgroups?Ans:( isn/2correct?
)(Idontthinkso.Ireadsomewhereits1+++
1/n)
Lettheslowestcarisatith.
Then0...iwillformonegroupand,fromi+1tonitisproblemofthesamekind.
icangofrom1ton.
Whatisnhere?numberofcarswithspeedsfrom1ton,andansis1+++...1/n
///how???useinduction
notnecessarylettheslowestcarbeatposition3
ex231.Youcansee231doesnotformonegroup.bcozcar2cannotreachcar3
hencetherearetwogroups
2)Presentvalue(PV)ofanamountcpaidafternyearscompoundedannually=c/
F(1+r)^n.Ifapersonpayscforever,everyyear,findtherelationbetweenPVandr(sum
ofinfiniteGP.PV=c/r)
IsPVvs.rgraphconvex?WillPVs3rdordertaylorexpansionunderestimateor
overestimateactualPV?ExpressionforPVifthecompoundedinterestistakenktimes
ayear?Whatisthelimitask>inf.(rememberexpressionforeinlimitterms)
3)TwopeopleAandBareplayingagameoffillingelementsofanemptymatrixoneby
one.Astartsandwinsonlyifthedeterminantofthefinal(completelyfilled)matrixis
nonzero,otherwiseBwins.IsthereastrategyforAtowin? anystandardprobitis?
2ndpartwastoevaluatedeterminantofanxnmatrixcontainingallcosterms.Dont
rememberexactentriesofthematrix. whatwastheapproach?anybody!
DataScience:
1) Classificationproblemdescribed.whichclassifierwillyouchoose?what
preprocessingwillyoudo?featureselectionetc.
2) whatwillbethesolutiontofollowingproblemsinalinearregressionproblem?
(poorperformanceontrainingset,poorperformanceontrainingset,
multicollinearityindata)
Doubt:QuantSubjective3:ForthepartwhenPViscompoundedktimesayear.Do
wehavetoconsidercamountispaideveryyearoritsaonetimepaymentaftern
years?
Ans.paideveryyearlikein1stcase
/
G.S@IITM//(GoldmanSachs)
sameasiitkseriously!Iwouldsaytheywillhavesame
questionsforexamonsameday,butadifferentonefor
differentdays.
.
Time:90minObjectiveand90minSubjective
someextraquestionsaddingtoabovelist:
Objective:
Quant:
10)TwofriendsAandBhave5musiccds.theyhaveaparticularpreference
order(withoutknowingtoeachother).ThenAwillseparateitslast2preference
fromthe5cdsandthenBwouldseparatehislast2preferencesfromthe
remaining3leftwithoneCDwhichtheywillplay.Nowwhatistheprobthat
neitherofthemlistentotheirfirstpreference.
ans) 3/20?correctmeifIamwrong.
shouldntitbe(2/3)*(2/5)?(yes) How?
Itis(4C1/5c2)*(2c1/3c2)...sameasabove
Descriptive:
CS:
3)Youhaveacontinuousstreamofdifferentintegersandwritecodeto
generatekrandomnumbersfromthestreamsuchthatselectinganintegerfrom
thestreamiswithequalprob(proveitandalsothateveryintegerisselected,for
+5marks)Youcannotaffordtostoretheintegers,butyoushouldgeneratek
randomintegersatanytimeinstantwhileyouareprocessing(whiletaking
streamasinputorsomethinglikethat).(marks5andanother5forproving.)
*youhaveaccesstoRandom(i)functionwhichwillreturnarandomnumberfrom
1toi1withequalprob.orrandom()functionwhichreturnsarandomfloatless
thanone.
//Anyone@IITM/@IITK,correcttheframingofthisquestionplease!!dont
rememberproperly.
DataSciencerelated :logisticregression,parametersinbayesian,adaboost,
SVMs,probabilityincaseofbiasedcoin,KNN,ANN,linearregression.(theseare
objective)
Subjective:Howwillyouhandleheteroscedasticityandmulticollinearityinlinear
regression.Whatifmodelisnotworkingwellontrainingdataandtestingdata,
youwilldoineachcase?
Someinformationaboutamachinelearningclassifierwasgivenwhichwas
modeledusingMAPestimate.Whichmodelisthis?
Onemorewasthere,idontrememberexactly!
Thanksguysformakingtheefforts!=>:)(y)gudnyt..
GoldmanSachs@IITG@IITRandIITKGP(IITBHUtoo)31/10/2015
NothingwasrepeatedfromIITMandIITK.
ObjectiveQuestions:
1. OSpagingquestion
2. Howtofindpathlengthof3betweentwoverticesiandjusing
adjacencymatrix(AnsA^3)
3. Whatifinsteadoflinearsearch,weapplybinarysearchforinserting
elementswhiledoinginsertionsort.Whatwillbethetime
complexity?
4. Ifnstringseachoflengthnistobesortedlexicographicallyusing
mergesort,thenworstcasetimecomplexity?
5. Aregularexpressionwasgivenandwehadtofindregulargrammar
forit.
6. Toimplement2stacksinanarrayefficiently,relationbetweentop1
andtop2(Geeksquizquestion)
SubjectiveQuestions:
1. GiventwodatastructureTreeMap[k,v]andHashMap[k,v].Usethem
tomakeanewdatastructurewhichsupports(onValuesnow):
a. extractmin(logn)
b. delete(logn)
c. insert(logn)
d. contains(O(1))
2.Makenewpackingalgototransfereverythinginasinglestrings.
Exampleifwewanttotransfer[a,ab,abc]wecanputlengthofthe
stringastheprefixofthestringandconcatenateallthestrings.
soitbecomes[1a2ab3abc].Soinnewstringwehave9characterstotal.
Compareyouralgowiththisexamplealgo.
3.AsurveywasconductedtoaskpeopleiftheywouldwatchthemovieThe
Martianornot.
TotalPeople:50
WillNotwatch:13
Willwatch:14
Noresponse:23
sothe%ofpeoplewhowillnotwatchis(13/(14+13))%.Butitturnedout
54.4%didnotwatchthemovie.Whatwentwrongintheestimation?
4.Provethatinacircularwirewithtempproportionaltolengthofwire.
Therearetwopointsdiametricallyoppositewhichhavesametemp.
5.Thereweretwocolumnsandwehadtomatchthem.ColumnIcontained
entrieslikecachingwebpages,assemblinganddeassemblinglarge
packets,convertingURLtoIpaddress,requestforretransmissionof
packet.ColumnIIcontainedthelayersatwhichthesetasksarehandled
likeTCP,IP,DNS,HTTPornoneofthese.
6.TherearetwoteamsatGSoneusingtableAandotherusingtableB.A
thirdteamusestableCwhichisjoinofAandBoveracommoncolumn
Entity.Anemployeeaccidentlydeletedthiscommoncolumnforthe
monthofOctober.NowhelphimfindtableCforthirdteambyusingdataof
last9months(whichwehave).
7.
a. Provethattraceremainssameinacyclicpermutationie
tr(ABC)=tr(BCA)=tr(CAB).
b.Provethatthereexistno3x3matrixpairAandBsuchthatABBA=
I3whereI3istheidentitymatrix.
c.Provethattheredoesnotexistpolynomialsp1(x),q1(y),p2(x),q2(y)
suchthatp1q1+p2q2=1+xy+(xy)^2
d.Giventhatx,y,zarerealnumberss.tx+y+z<=1.thenfindthemaximum
valueoffunction(x^2*y+y^2*z+z^2*x)
8.Provethat summmation(nCr)^2=2nCn
9.Lettemperatureoftheringbeacontinuousfunction.Provethattherearetwo
diametricallyoppositepointsthathavethesametemperature.
10.Somequestiononbiddingetc..onepartwasweird.restseemedokayish..
Flipkart@IITDelhi29thOctober
2programmingquestionsonhackerrank90mins
Q1.ProgresstrackerYouhavetotransferyourfilesfromexternalhard
drivetodesktop.Thetimetakenforthetransferisrepresentedas
HH:MM:SS.Apercentagedepictingthetransfercompletedisdisplayedfor
wholevaluesofseconds.0and100%arenotincluded.Howmanytimes
willthepercentagebedisplayed.
Foreg.00:10:00apercentageincreaseby1%every6seconds.So,99
ticks
00:14:00apercentageincreaseof5%every42seconds.So,19ticks.
Q2.WineglassesYouhavetoplacenwineglassesincardboardboxes.
Eachcardboardboxhaslengthlandwidthofglassisw.Aunitdistance
hastobeleftbetweentheglasses.Glassesareplacedwithinaboxifthe
numberoftheglassesinaboxisnotdivisibleby13.Whatistheminimum
numberofboxesrequired.
Foreg.n=8,w=2,l=5so4cardboards
n=26,w=2,l=80so2cardboards////Itshouldbe1cardboard
80/(2+1)=26+2////Itwontbe1cardboardasdivisibleby13isnotallowed.
Solutionforthis?
Microsoft@IITB
Friday,30.10.2015
platform:Cocubes
30minApti
1Hrcoding
Aptitude:15Questions(thereweresetsforeachstudent)
FewquestionsIremember:
1)Thenumberofleafnodesinarootedtreeofnnodes,witheachnodehaving0or3children
is:
ans:(2n+1)/3(Geeksquizquestion)
2)Fetch_And_Add(X,i)isanatomicReadModifyWriteinstructionthatreadsthevalueof
memorylocationX,incrementsitbythevaluei,andreturnstheoldvalueofX.Itisused
inthepseudocodeshownbelowtoimplementabusywaitlock.Lisanunsignedinteger
sharedvariableinitializedto0.Thevalueof0correspondstolockbeingavailable,while
anynonzerovaluecorrespondstothelockbeingnotavailable.
AcquireLock(L){
while(Fetch_And_Add(L,1))
L=1
}
ReleaseLock(L){
L=0
}
Ans:failsasLcantakeonanonzerovaluewhenthelockisactuallyavailable
(GeeksQuiz)
3)HowmanypatharetheretoreachfromAtoB
AisbottomleftBisatTopright.
Darkrectangleindicatesthereis bridge
.
//whattoinferfrombridge,cansomeoneexplain
B
options:a)165b)170c)195d)209
Ans??didsomeonegettheansforthis?
(How??)wasntthereaconditionlikestepsshouldbeminimum?Otherwiseitcangotoinfinity
(goingintoaloop)oratleastaconditionlikewecangoonlyonceonanyblock.
4)&5)
TwoQuestionsonlinkedlist:Whatistheoutput(NotrememberingexactQuestions)
Listwasgiven12345678Someoperationonlistandlistwasprintedatlast.
6)
QuestiononVirtualFunction:(Whatisoutput)
3classesweregiveneachoverridingsamefunctionofbaseclass.
Arrayofbaseclassstoringobjectsof3classes.Thenacalltofunctionsmade.
7)
QuestiononJavaCharArray,characterstream.(Whatisoutput)
8)
WhatisoutputofthisC++code:(notrememberingexactcode)
ConversionOperatoroverloading:
9)
QuestiononCpreprocessing9(Notrememberingexactly)
Butwassomewhatlikethis:
#defineap(m,n)m##n
#defines(x)#x
intmain(){
intm=14,n=4
do{
printf(%d,ap(m,++n))
}while(s(90),4)
Options:a)11,b)compileerror,c)..,d)..
doubt:whatwillwhile(s(90),4)do.Ithinks(90)=90right??
10)&11) QuestionsonStructurepointers
12)
ConsideraweightedcompletegraphGonthevertexset{v1,v2,..vn}suchthatthe
weightoftheedge(vi,vj)is2|ij|.TheweightofaminimumspanningtreeofGis:
(A)n1(B)2n2(C)nC2(D)2
(GATECS2006)
ans:2n2
13) Consider the following array of elements. 89, 19, 50,17,12,15,2,5,7,11, 6,9,100.The
minimumnumberofinterchangesneededtoconvertitintoamaxheapis:
a)3b)4c)5d)2
ans:3
14)15)Notremembering
PART2)Coding:Twocodingquestions:
Platform:cocubes
1)LongestEvenLengthSubstring
part=sumofrightpart.Return0ifnosuchsubstringexists.e.g.givenstring1523457
Thelongestevenlengthsubstringwillbe5234
sooutput=4
2)Minimumdifferenceofsubarray
ofeachsubarrayshouldbeminimum.forevenn:subarraylengthsshouldbn/2exact
foroddn:subarraylengthsshouldbe(n1)/2and(n+1)/2
e.g.givenarray5,6,11,13,14,25twosubarrays:{5,6,25}and{11,13,14}
diffbetweensums=2
sooutput2.
//DIDBRUTEFORCEWORKFORTHISONE,i.e.creatingallpossiblesubsetsofsizen/2
//Also,howmanytestcases(forboth)?
PFAScreenshots
Microsoft@IITB
Flipkart@IITMsame@IITBsame
asIITDalsoincludingstring
similarity@IITG
3Questions:
https://www.hackerrank.com/challe
nges/stringsimilarity
ExpertlevelQuestion??
Solution????
OracleCodingRound@IITG
Q1.Youaregivensomestringsandaskedtoidentifytherepeatedstrings.
eg.abcabd
soansweris2sinceat4thand5thplaceaandbisrepeatedonce.
(SimplybytheuseofMap)
Q2.https://leetcode.com/problems/wordladder/
youaregivenonestartstringandoneendstringandadictionaryofstrings.You
havetotellinhowmanystepsyoucantransformstartstringtoendstringusing
intermediatestrings(dictionaryones).constraintisthatforanystepyoucan
changeonlyoneletteroftheexistingstring.
eg.
start=abc
end=xyz
dict=abzaxzpxzpyzxyz
sointheabovecasetransformationisabc=>abz=>axz=>pxz=>pyz=>xyz
ateverystepstringischangingbyoneletteronly..
Soanswerwillbe6inthiscase..
Platformwaslikeshit.noc++14support.Onlytwotestcasewasthere,idont
knowwhethercodewillbecheckedafterthosetwostupidtestcasesornot.
REMEMBER:Changelanguageofthesolution(ifyouusec++orJAVA)before
solvingeachquestionbecausedefaultlanguageisCandyoucannotpastethe
solution.*(gothroughgraphdfsandbfsquestionsespeciallythoseoninterview
bit)
//musthavebeenhellifsomeoneforgotto
IITBHUSRIBQUESTIONS:P
Q1)Hereyou'vetofindnumberofH,L,T,UinaNxNgrid(containsonly0
and1)
Eachpatterncanberepresentedinformof3x3matrixandcanberotated
in90,180,270degrees
H101111
111010
101111
L100
100andthreemoreforms
111
T111
010andthreemoreforms
010
U101
101andthreemoreforms
010
sampletestcase
001110100
000010111
000010100
000000000
111000110
010000001
111000110
output>1111
Itisguaranteedthatavalidpatternexistsandtwopatternsareseparated
byboundaryofone.
Q2)GivenheightofN*NbuildingsinformofNXNmatrixandaballcanbe
assumedtobedroppedfromabuilding.
ballwillfallonitsneighbourhavinglowestheight.
e.g.ballfroma[i][j]willfallonmin(a[i+1][j],a[i1][j],a[i][j+1],a[i][j1])and
goesonfalling.
youhavetofindlengthofmaximumpaththatcanbetraversedbyball.
input
3x3
123
489
605
output>4(9>3>2>1)
IITD...KLATencor
ApplicationDeveEngi
1. 15Aptiquestionin60minutes
Algoprofile:
1. 4Programingquestions
2. 10Aptiquestions
OracleCodingRound@IITBHU
Time:1hour
2questions
Q1.Givenagraphintermsofadjacencymatrixandmcolours,printwhetheritis
possibletocolourthegraphinsuchawaythatnotwoadjacentverticesshare
thesamecolour.Also,printthenumberofminimumcolourrequired.
Inputformat:Firstlinecontainsn,mwherenistheno.ofverticesandmisthe
no.ofcoloursprovided,Nextnlinescontainsnintegerseachtogether
representingtheadjacencymatrix.
OutputFormat:twospaceseparatedintegers,firstis0or1denotingwhetherit
ispossibletocolouritinmcolour.Seconddenotingtheno.ofminimumcolour
required.
Q2.Princehastosaveprincess.Sheisinthecell(a,b)ofarectangulargridof
size(m,n).Hestartsfrom(1,1)andmovestotheprincessmovingright,left,
downorup.Whenheenterssomecellhehastokillalltheguardsinthecell
beforeleavingthecell.Thiskillingtakessomeamountoftimedependingonthe
cell.Letussay,ittakesc[i,j]amountoftimetodoso.Thereisabombthatblow
theprincessinsometimesayt.Printwhetherornotthereexistsapathfrom
(1,1)to(a,b)suchthathesavestheprincessbeforethebombgoesof.Ifthere
existssuchpath,printthemaximumamountoftimehecansparewithprincess
beforethebombexplodes.
WalmartLabs@IITBHU
Platform:Hackerearth
Questions:3
1.Givenastringscontainingonlynumbers0to9.Youareallowedtodom
operationsonthestring,findthelexicographicallylargeststringthatcanbe
generated.Anoperationisdefinedasswappingoftwoadjacentcharacters.
InputFormat:Firstlinecontainsthestringandsecondcontainsm.
Ex.
2159467
5
Output:
9521467
2.Givenarootedtreeofnnodes.Eachnodebeingnumbered1tonandeach
hasavalueassociatedwithit.Therootofthetreeisgivenasr.Youhaveto
performtwotypesofqueriesonthetree.Firstqueryisrepresentedas"suma"
whereyouhavetofindthesumofallvaluesofnodesinthesubtreerootedata
(i.e.sumofvaluesofallnodesgoingdownfromaandincludingthevalueat
nodea).
Secondqueryisrepresentedas"updateav"whereyouhavetoincrementthe
valueofnodeabyv.
Inputformat:
Firstlinecontainsnandr,wherenisthenumberofnodesandristherootofthe
tree.Nextlinecontainnintegersdenotingthevalueofeachnode.Thenn1lines
follow,eachcontainingtwospaceseparatedintegersuandv,suchthatthere
existsanedgebetweenuandv( notethatitwasnotspecifiedwhoistheparent
uorv).Followedbyanumberqdenotingthenumberofqueries.Inthenextq
linesarethequeries.
3.Avaritationof
http://www.spoj.com/problems/AGGRCOW/