Você está na página 1de 63

Pleaseaddallquestioorninthisdocwithheading

Companyname@CollegeName,Date

Pleasegrouppapersofsamecompanytogether

CONGRATULATIONSTOEVERY.WehavedecidedatPGABthatfro
WorksApplicationQuantitativetest,Mathsbased,prettyeasy

DIRECTI@IITKGP18NOV

You are given a rectangular grid with 2 rows and N columns. The top row is labeled 1 and the bottom row islabeled2.The
columnsarelabeledfrom1toNinincreasingorder.Eachcellinthegridcontainsasinglecharacter.
Consider a hamiltonian walk in this grid. Meaning, pick a starting cell, say (i,j), and consider a path that starts from (i,j) and
goes through every cell in the grid exactly once. Note that you can only walk to adjacent cells, or cells that you sharea
common edge with. There may be several such paths. Let us concatenate the characters in the order in which thecellsare
visitedduringawalk.Thestringformedcanbecalledthestringforthewalk.

Among all the possible walks, and their respective strings, find out the lexicographically smallest string. We know that the
length of thestringsareallthesametobeprecise,2N.Thus,thelexicographicallysmalleststringissimplythe alphabetically
smalleststringifyoucomparethecharactersfromlefttoright.

Input
ThefirstlineofinputcontainsanumberT,thenumberoftestcases.ThenfollowTtest cases.Each testcasecontains3 lines.
Thefirst linecontains the number N, the number of columnsinthegrid.Itis wellknownofcoursethatthe grid containsrows.
Thenext two lines contain the description of the grid in the form of two stringsthestringofNcharactersinrow 1fromleftto
rightandthestringofNcharactersinrow2fromlefttoright,respectively.Eachcharacterwillbealowercaseenglishletter.

Outputlabs

Output a single line for each test case. The line must contain a string with 2N characters. This string should be the
lexicographicallysmalleststringforsomehamiltonianwalkinthegrid.

Constraints
1T1001N10

SampleInput
2
gm3
abc
def
10
ababaaabab
bababababa

SampleOutput
abcfed
aaababababababababab

Explanation
In the first test the possible strings are { abcfed, adebcf, adefcb, badefc, bcfeda, cbadef, cfedab, cfebad,
dabcfe, dabefc, defcba, edabcf, efcbad, fedabc, fcbade, fcbeda }. The smallest string is abcfed.

You are given a large array of 10,000,000 bits. Each bit is initially 0. You perform several operations of the type"Flipallthe
bitsbetween start_index and end_index, inclusive". Given a sequ
ence of several such operations, performallthe operations
on the array. Finally, split the array into sets of4bitsfirstfour,nextfour,thennextfour and soon.Eachsetcan representa

hexadecimal integer. There will be exactly 2,500,000 hexadecimal integers. Calculate the frequency of each of the
hexadecimal integers from '0' to 'f' among the 2,500,000 integers, and print it. See Input / Outputandexplanation of Sample
Input/Outputforclarity.

Input
Thefirst lineof inputcontainsanintegerT(1T10), thenumberoftestcases.ThenfollowsthedescriptionofTtestcases.
You should assume thatthearrayhasexactly10,000,000 bitsandthatthebits areallunsetatthestartofeachtestcase.The
first line of each test case contains an integer N (1 N 10,000),the number of operations performed. The next N lines
contain two integers separated by a space, the start_index and end_index for the respective operation. Note that the flip
operation is performed fromstart_indextoend_index,inclusive.Also,the arrayis 1indexedmeaning, thesmallestindexis1
andthelargestindexis10,000,000.

Output
For each test case, output 16 integers on a single line, separated by single space characters. The first integer should
represent the number of times 0 occurs among the 2,500,000 hexadecimal integers created according to the problem
statement. The second integer should represent the number of times 1 occurs among the 2,500,000 hexadecimal integers
createdaccordingtotheproblemstatement,andsoon.

Constraints
1start_indexend_index
start_indexend_index10,000,000

SampleInput

2
2
14
999999710000000
2
36
58

SampleOutput
2499998000000000000002
2499998002000000000000

Explanation
In thefirst test case, after we perform the two operations and split the array into 2,500,000 groups of4 bits, thefirstandthe
lastgroupwillhaveall4bitssetrepresenting'f'hexadecimaldigit.Alltheothergroupswillhaveall 4bitsunsetrepresenting
'0'hexadecimaldigit.

In thesecond test case, after we perform the two operations and split the array into 2,500,000 groups of 4 bits,thefirsttwo
groupswill have the state 0011. This represents the hexadecimal digit '3'. All the other groups will have allthe 4bitsunset
representing'0'hexadecimaldigit

BrowserStackRound2@IITBHU(151114)

Total5to6hourstime.3Questions.Googling,useofanyothersitewasallowed.

Ques1.)

InthisprogramyouhavetoconsumeTwitter.comsRESTAPI.

Writeaprogramthat,givenahashtagHandanumberN,
fetchestheNmostrecentimages(noduplicates)associatedwiththathashtag
andgeneratesawebpage(anHTMLfilewoulddo)whichdisplaystheseimagesasasimple
slideshow

YoumayattemptthisprobleminanyprogramminglanguagebutyoumayNOTuseathirdpartylibrary
like
twitter4j
.YoumayhavetocreateanewTwitteraccountifyoudontalreadyhaveone.Visit

Twitter
AppManagement
toregisteranewappandobtainanAPIkey.See

TwitterRESTAPIdocs
formore
details.

Ques2.)

Considerthewebserverloginthefile

sample.log

Writeashellscript(zsh/bash)thatparsesthisfileandoutputsthefollowing:
1. thenumberofHTTP404errorsinit
2. alistofallHTTPresponsecodesinthelogandtheircount

Youmaydownloadthelogfileandsaveitlocallyfortestingpurposes.Forthesecondpart,yourscript
mustfindallresponsScrapeIMDBtop250listandmakeaknowledgebasewhichsupportsqueryfor
topmoviesofanygivenactoScrapeIMDBtop250listandmakeaknowledgebasewhichsupports
queryfortopmoviesofanygivenactoScrapeIMDBtop250listandmakeaknowledgebasewhich
supportsqueryfortopmoviesofanygivenactoScrapeIMDBtop250listandmakeaknowledgebase
whichsupportsqueryfortopmoviesofanygivenactoScrapeIMDBtop250listandmakeaknowledge
basewhichsupportsqueryfortopmoviesofanygivenactoecodesinagenericfashion,youshould
nothardcodesearchesforaknownlistofresponsecodes.Thescriptmustbeashellscript
Perl/Python/Rubyare
not
acceptable.

Ques3.)
ScrapeIMDBtop250listandmakeaknowledgebasewhichsupportsqueryfortopmoviesof
anygivenactor.


MICROSOFT@IITBHU+IITK(061114)

1hourtestconductedoncocubes.com
2codingquestionsonly.
Questionssameforallthestudents.
LanguagesOnlyC,C++,Java,C#wereallowed.

Ques1.)ConvertabinarytreeintoitsMirrortree.
Condition:Inplaceconversionrequired.

Ques2.)Givenanumber,returnthenumberofsetbitsofthenumberifbinaryrepresentation
ofthenumberisapalindrome,elsereturn1.
Condition:Youcantusearrayoranyotherdatastructure.
Eg.Input
37 tr
Output 1

Input
165
Output 4

MICROSOFT@IITD+IITKGP+IITM(061114)

1hourtestoncocubes.com
2codingquestionsonly.
Questionssameforallthestudents.
LanguagesOnlyC,C++,Java,C#wereallowed.
1.
Givenanarrayofintegers,findanindexsuchthatsumoftheelementofleftside=sum
ofelementofrightsidenarrayofintegers,findanindexsuchthatsumoftheelementof
leftside=sumofelementofrightside
input:12131816
o/p:2because12+13=18+1+6
2.
Givenanarrayofintegers,findthemaximumcontinuoussumsuchthatnoelements
contributingtothesum,arerepeated.
I/p:1233452
o/p:14as3+4+5+2=14


MICROSOFT@IITG(061114)

1).
http://www.geeksforgeeks.org/kthsmallestelementinarowwiseandcolumnwisesorted2d
arrayset1/

2).Givenabinarytreeandanumber.Ifthetreehasaroottoleafpathsuchthataddingupall
thevaluesalongthepathequalsthegivennumber,returndepthofthatleaf(minimum,if
multiplepaths),Return1ifnosuchpathcanbefound.

DirectIQuestionsLinks
(SamequestionsaskedinallIITstillnow)

http://www.codechef.com/DI14R018t
lITBHU

http://www.codechef.com/DI14R019
IITBHU

http://www.codechef.com/DI14R024
IITM(SetBitsandSmallestRectangular

Stringproblem)
@IITMguyspleasepostscreenshots.Thelinkis
unaccessible.

@IITDelhi
ColorfulKnapsack
+
Best2x2Sudoku
@IITG@IITB

Adobe@IITBHU(41114)

2Sections,10questionseachsection,totaltime2hours,Fullsubjective.
Paperandpentest.AllquestionsrelatedtoCSE.Noaptitudequestions.NoMCQs.

Somequestions:

somemicroprocessorcodegiven,tellanswer

LCAof2nodesinBST

returnpointertomiddleoflinkedlistin1pass

Array ofsize n1hasnumbers 1 to n, onenumber missing,no number repeated, find themissing


number

WhatisthebestSTLusedtofindmatchingparenthesis

sometheoreticalquestionsonpointersandfunction

findGCDusingrecursion

findmax.of3numbersusing?:only

reverseadoublylinkedlist

find2'scomplimentofano.giveninstringform

somemacrorelatedquestions

GivenaHashfunction,findvalueofkeyshavingsamehash

Givenorderofinsertionofnodes,makeBST

given3AC,anumberinbase14,convertittobase7.(onlyshowworkingongivenexample,nocodeor

algo)[ans=2105]

Simplifyagivenbooleanexpression.

Explaina)&b)
a)void(*p)(void*a[],intn)
b)void*(*p[])(void*a,intn)

@IITM

13GATEpatternMCQsand7CodingQuestions
Platform:HackerRank
TIme:2hrs

CodingQuestions:
1.

Reverselinkedlist

2.

Checkbalancedparentheses

3.

Givenm*nbinarymatrix,whereeachrowhasall1sfirstandthenall0s.Youneedto
returnrownumberwhichhasmaximum1s.

4.

Everyintegerendingwith3hasatleastonemultiplewhichismadeofonly1s.Ex.3
has111,13has111111.Givenintegern(LSDis3),returnitssmallestsuchmultiple.

MCQs:
1.

charstr1[]=Hello
charstr2[]=Hello
if(str1==str2)
cout<<Equal
else
cout<<NotEqual

2.

charstr1[]=Hello
str1[6]=b
cout<<str1

Citrix
Citrix@IITB(261114)
Platform:Hackerearth
1hour:50MCQs(aptitude,networking,c++(constructor,destructor,base,derived,operator
overloading),OSetc)nonegativemarking
1hourcoding(Repeated)
1. Findthenumberofconnected1sinmatrix
(Questionisastorycontainingthese
words:ByteVille,BitVille,HobbleScope)
2. Determinantofamatrix.
IusedtheusualminorcalculationapproachittakesO(n!)and
gotaccepted.Itrunsimmediatelyforupto9x9matrix.So,Idontthinktheyusedany
largermatrix

Citrix@IITG(061114)
50MCQincludingcodesnippet,OS,Aptitude,Network
Three Englishmen and three Frenchmen work for the same company. Each of them knows a
secret not known to others. They need to exchange these secrets over person-to-person phone
calls so that eventually each person knows all six secrets. None of the Frenchmen knows
English and only one Englishman knows French .What is the minimum number of phone calls
needed for the above purpose?
(A) 5

(B) 15

(C) 9

2CodingProblems

(D) 10


1>
FindingPrimeNumbersbetweenTwoNumbers

2>Determinantofamatrix.

IITKGP

Platform:HackerEarth
Q1.NumberofIslandsinagivenmatrix

6+

Q2.GiventwoStringsfindwhetherallthecharsoffirststringarethereinsecondstringornot.
len(str2)>len(str1)insecond.Stringmaycontainspecialcharsalso.

Note:
ReadingInputwasthemainproblem.Boththestringswillbegiveninalinewitha
verticallinebetweenthem.Alsostring1andstring2mightcontainspaces
Ex:
Input:
Iamabadboy|Iamnotabadboy

IITKGPcitrixwrittenquestions.
(1houraptifollowedbyanother1hourcoding(2que))

1.Dontremembertheactualquestionbutitwasrelatedto8connectedness,i.egivenamatrix
of1'sand0'syouneedtofindnumberofclustersof1's.cluster>foranycellinmatrixevery8
adjacentcellforthatcellwillbeinthesamecluster.

2.Giventwostringscheckwhetheroneispseudoanagramofother.
conditions:
(i)onlylettersneedtobeconsidered.T
e.g.abcdandbc"ad?arepseudoanagrams.
(ii)caseinsensitive.
e.g.abCdandBCaDarepseudoanagrams.
(iii)repetitionofcharactersisallowed.

e.g.abcdandbccaaadarepseudoanagrams.

aptitude:
somec,c++programs,os,quantapti,n/w.......nottough

Codenation@IITKGPandIITB
Platform:HackerRank

Duration:1hr45min
3Codingquestions

Q1.Givenrangeoflengthofthreesidesofarectangleasl1,u1,l2,u2,l3,u3.Here(l1,u1)is
minmaxlengthofthebaseandothertwoaresideswithrightangle.Youhavetofindout
possibleminmaxlengthof4thsidewhichcanbeconnectedwithtwosides.Hereangle
between4thsideand2nd,3rdneednottoberightangle.
Sampletestcase1:
Input:
4,4
3,3
3,3
Output:
4,4
Note:Inputsarecommaseparatedtwonumbers
Sampletestcase2:
Input:
10,12
4,8
3,6
Output:
10,13(Explanation:10whenbothsidesareequaland13whendiffisGivenrangeoflengthof
threesidesofarectangleasl1,u1,l2,u2,l3,u3.Here(l1,u1)isminmaxlengthofthebaseand
othertwoaresideswithrightangle.Youhavetofindoutpossibleminmaxlengthof4thside

whichcanbeconnectedwithtwosides.Hereanglebetween4thsideand2nd,3rdneednotto
berightangle.5)

Q2.
http://www.hackerearth.com/pro.../algorithm/magicfractions/
Q3.GivenaninputmatrixwhichhasYinthecell(i,j),ifpersoniiscomfortabletalkingto
personj,ourtaskistofigureoutwhatarethemaxnumberofpeoplethatcanbekeptengaged
amongstthemselves.
Note:Aguestcantalktooneguestatatime,effectivelykeepingbothofthemengaged.

Input:
5(Numberofguests<=50)

NYNNY
YNNNN
NNNYN
NNYNN
YNNNN

CodeNation@IITK&@IITR&@IITD&@IITM

Q1.(NotethatCyclicPermutationhereisnotthesameasthestandarddefinition,soread
carefully)
Givenasequenceofnumbers1,2...N,theorderofthepermutationisthenumberoftimesthe
permutationhastobeappliedinordertogetbacktotheoriginalsequenceofnumbers.The
icyclicpermutationisonewhichmovestheallthenumbersaheadbyi.Iteffectivelyrotates
thearraybyielements.
Consideracyclicpermutationof2forN=3.Effectivemappingforpermutationwillbe:1>3,
2>1,3>2
Thishastobeapplied3timestothesequencetogetbacktotheoriginalsequence1,2,3>
2,3,1>3,1,2>1,2,3
Hence,theorderoftheabovepermutationis3.
GivenaninputN,printthenumberofdifferentordersthatitcanhaveacrossallit'scyclic
permutations.
Note:Nwillalwaysbegreaterthan0andlessthan500
Example:
1)

Input:
3
Output:
2
Explanation:Thereare2possiblepermutationordersof3forit'scyclicpermutation:1(forthe
identitypermutation),and2(cyclicpermutationsof2and3)
2)
Input:
4
Output:
3
Explanation:The3possibleordersare:1(identitypermutation),2(cyclicpermutationof2),4
(cyclicpermutationof1and3)

Q2.WehavetwostringsAandBwiththesamesupersetofcharacters.Weneedtochange
these
stringstoobtaintwoequalstrings.Ineachmovewecanperformoneofthefollowing
operations:
1swaptwoconsecutivecharactersofastring
2swapthefirstandthelastcharactersofastring
Amovecanbeperformedoneitherstring.
Whatistheminisupersettheircharactersareequal.
1<=length(A)=length(B)<=2000
Alltheinputcharactersarebetween'a'and'z'
OutputFormat:
Printtheminimumnumberofmovestotheonlylineoftheoutput
Sampleinput:
aab
baa
Sampleoutput:
1
Explanation:
Swapthefirstandlastcharacterofthestringaabtoconvertittobaa.Thetwostringsarenow
equal.

Q3.Babaiisstandinginthetopleftcell(1,1)ofanNxMtable.ThetablehasNrowsand
Mcolumns.Initiallyheisfacingtotherightcell.Hemovesinthetableinthefollowing
manner:
Ifthecellinfrontofhimiswithinthetableandunvisited,hethenmovesonestepforward
intoit,andturnstohisright.
1.
Otherwiseheturnstohisright,andtriesstep1again.2.
Ifhehasnorightturnsremaining(hehastriedstep2fourtimes),thenhestops.3.
Hemovesaroundthetableandvisitsasmanycellsashecan.Yourtaskistofindoutthe
numberofcellsthathevisitsbeforehestops.Here'sasampleofBabai'sstepsona9x9grid.
Thevalueateachcelldenotesthestepnumber.
1255545150474645
4356535249484344
5657587978774241
8760598075763940
91061628174733837
121164636869723536
131465666770713433
161520212425282932
171819222326273031
Inp
TheinputcontainstwointegersNandMseparatedbyaline.NandMarebetween1and100.
Output:
Printasingleintegerwhichistheanswertothetestcase
Sampleinput#00:
3
3
Sampleoutput#00:
9
Sampleinput#01:
7
4
Sampleoutput#01:
18

FLIPKART

FlipkartatIITdelhiGraduateTraineeProfile

Facebook

Flipkart@IIT(BHU)Varanasi

Hostedon:hackerrank.com

Time:90minsNoobjectivequestions.

Anyonewithanswersofabovemcqs?
Two
codingquestions.Wehavetocompletethefunctiononly.

Oneofthequestions
numberofstripsrequiredtocoverthewholegrid.
Note:onlythecoloredpointsshouldbecovered.Pointswith'.'shouldremainasitis.
1<=m,n<=100
Ex.
Input

24
..B.
..B.
Output
1

Input
55
..B..
..GRR
..B..
R.
R....
Output
4

\Input
55
..B..
..GRR
..B..
B....
B...G
Output
5
Input1
34

GGGG
GRRG
G..G
Output
8
Explanation:
Bluestripsarevertical.
Redstripsarehorizontal.
Ex1:
Only1verticalstripfrom(0,2)to(1,2).[Indexingfrom(0,0)]
Ex2:
1verticalstripfrom(0,2)to(2,2)
1horizontalstripfrom(1,2)to(1,4)

1horizontalstripfrom(3,0)to(3,0)
1horizontalstripfrom(4,0)to(4,0)
sototal4
Ex3:
1verticalstripfrom(0,2)to(2,2)
1horizontalstripfrom(1,2)to(1,4)
1verticalstripfrom(3,0)to(4,0)
1horizontalstripfrom(4,4)to(4,4)
1verticalstripfrom(4,4)to(4,4)
sototal5
Ex4:
1.)Givenamxngrid,eachofit'selementbeeither'.','R','G'or'B',
where'.'>empty,'R'>Red,'G'>Green,'B'>Blue
ABluestriphaswidth1andlengthgreaterorequaltoone.[Vertical]

ARedstriphaslength1andwidthgreaterorequaltoone.[Horizontal]
IfaRedstripandaBluestripoverlaps,theoverlappedportionwillbecome'G'.w
Findtheminimumn
1horizontalstripfrom(00)to(0,3)
1horizontalstripfrom(1,0)to(1,3)
1horizontalstripfrom(2,0)to(2,0)

1horizontalstripfrom(2,3)to(2,3)
1verticalstripfrom(0,0)to(2,0)
1verticalstripfrom(0,1)to(0,1)
1verticalstripfrom(0,2)to(0,2)
1verticalstripfrom(0,3)to(2,3)s
sototal8

SAMSUNG

SamsungIndia(R&D)atIITMadras,20/10/2014
2
Rounds:
Round1:60mins
Tip:AttempttheMathpartfirstandVerbalthelast.
ShortlistbasedonscoreinRound1
Round2:codinground1hr
Questions
Onlineweredifferentfordifferentpeople.Questionscollectedfromalimitedpoolofquestions
andjumbledsequencewords)wasignoredbecausewelimitqueriesto32wordforeveryone.

3questionsforA:x
1.Givenastrings1removealloccurrencesofthestrings2instrings1andalsoremoveall
occurrencesofstrings2afterremovalofs2ins1andsoon..andreturnthestringobtained
aftersuchremovals.[5points]
Example:s1="qwewerrty"s2="wer"
Output:qty
(Onthefirstremovalofweritbecomesqwerty.Onremovalagainnowqty.Nothingto
removenow.)
2.

astring,printthenumberofoccurrencesof1[0]*1where*denoteszeroormore
occurrencesofthedigit0.[5points]

Input:10011abc10000001
Output:3

3.Questionhadsomerobotandstorybuildupbuttheessenceisthis:
Youaregivenan
mxngrid
,where(0,0)referstopmostleftpositionand(m1,n1)thebottom
mostright.Thegridisfilledwithones.Allpositionsinthegridthatareblockedarefilledwith
zeros.Youaregiventhisgridandareassuredthatthereexistsatleastonepathfrom(0,0)to
(m1,n1).Findtheminimumdistanceofthepathfrom(0,0)to(m1,n1)giventhatyouare
allowedtomoveonlyvertically,horizontallyanddiagonally.[8points]

AnothersetofquestionsforRound2.Addingthecommenthereforbettervisibility.
1.(5points)SameasA'ssecondquestion.
2.(5points)Giventwolinkedlists,whereeachnodeofalistcontainstheexponentsand
coefficientsofapolynomial(indecreasingorderofexponents,zerocoefficientsdon'thave
nodesassociatedwiththem),performmultiplicationofthetwopolynomialsandreturnalinked
listwiththeresult(conditionssimilartotheinputdecreasingorderofexponents,termswith
zerocoefficientsshouldnotbepresentinthelinkedlist)
3.(8points)Givenawordwithuniquelowercasecharacters,returnitsrankinadictionarythat
consistsonlyofwordsthatareanagramsofthegivenword.

Eg:"take":6wordsstartwith'a',6with'e',6with'k',1witht,andfinally"take",soitsrankis6
+6+6+1+1=20.

1.Determinewhethertheanagramofagivenstringcanbeapalindrome.
2.SameasA'sfirst.
3.You'regivenanarrayofintegers.Returnthelargestnumberyoucanmakeusingallthe
digitsinthearray.e.g:a=[23,45,67],return765432.(concateverything,sortandreturn.)

Directi

Directi@IITR,18thOctober2014
2Questions
90min.
Platformcodechef
Q1:
TheithstonehasthecolorC[i](between1toM,inclusive).
TheKnapsackcanholdatotalweightofX.Fillknapsackwiththesestones.we
havetoselectexactlyoneofeachMstonecolors.
sumoftheweightsofthestonesmustnotexceedX.

WehavetofilltheKnapsackasmuchaspossible.(henceminimizeunusedcapacity.)
Input
numberoftestcases.
Thefirstlineofeachtestcasecontainsthreeintegers,N,MandX,
TheNintegers,W[1],W[2],W[3]...W[N],(Weight)
NintegersC[1],C[2],C[3]...C[N],
OutputtheunusedcapacityoftheKnapsack(asingleintegeronalinebyitself)foranoptimal
way.IfthereisnowaytofilltheKnapsack,output1.
Constraints

1T10
1M100
MN100
1W[i]100
1C[i]M
1X10000
SampleInput
3(testcases)
9310(1sttest)
234234234(wt)

111222333(color)
9310(2ndtest)
135135135(wt)
111222333(color)
3310(3rdtest)
344(wt)
123(color)
SampleOutput
0
1
1
Note:bruteforcesolutionwillfail.

Q2:
Thereisabitarrayoflength10000000.sAnoperationisperformedseveraltimesonthisarray
withgivenstartandendindices(onepair).Anoperationflipsallbitsb/wstartandend
indices(inclusive)ofbitarray.AftertheNoperations,youneedtotellthefrequenciesof16hex
digitsinthatarray.
0<=N<=1000.
Note:Therewillbeexact2500000hexdigits.
fliInput:

1(#oftestcases)
2(#ofoperations)
36
58
Output:

2499998002000000000000

Note:Eachpairof4bitsrepresentsahexdigit.
:Intheexample,bitsafter1stop:00111100s..
:after2ndop:0011001100.
:So,thereareand23srestofthemare0s.
Note:BruteforcewillgiveTLE.

Directi@IITM

two2questions
90min

q1
setbits

You are given a large array of 10,000,000 bits. Each bit is initially 0. You perform several operations of the type"Flipallthe
bitsbetween start_index and end_index, inclusive". Given a sequence of several such operations, performallthe operations
:onthe array. Finally, split the arrayintosetsof4bitsfirstfour,nextfour,then nextfourandso on.Each set canrepresenta
hexadecimal integer. There will be exactly 2,500,000 hexadecimal integers. Calculate the frequency of each of the
hexadecimal integers from '0' to 'f' among the 2,500,000 integers, and print it. See Input / Outputandexplanation of Sample
Input/Outputforclarity.

Input
Thefirst lineof inputcontainsanintegerT(1T10), thenumberoftestcases.ThenfollowsthedescriptionofTtestcases.
You should assume thatthearrayhasexactly10,000,000 bitsandthatthebits areallunsetatthestartofeachtestcase.The
first line of each test case contains an integer N (1 N 10,000),the number of operations performed. The next N lines
contain two integers separated by a space, the start_index and end_index for the respective operation. Note that the flip
operation is performed fromstart_indextoend_index,inclusive.Also,the arrayis 1indexedmeaning, thesmallestindexis1
andthelargestindexis10,000,000.

Output
For each test case, output 16 integers on a single line, separated by single space characters. The first integer should
represent the number of times 0 occurs among the 2,500,000 hexadecimal integers created according to the problem
statement. The second integer should represent the number of times 1 occurs among the 2,500,000 hexadecimal integers
createdaccordingtotheproblemstatement,andsoon.

Constraints

1start_indexend_index
start_indexend_index10,000,000

SampleInput
2
2
14
999999710000000
2
36
58

SampleOutput
2499998000000000000002
2499998002000000000000

Explanation
In thefirst test case, after we perform the two operations and split the array into 2,500,000 groups of4 bits, thefirstandthe
lastgroupwillhaveall4bitssetrepresenting'f'hexadecimaldigit.Alltheothergroupswillhaveall 4bitsunsetrepresenting
'0'hexadecimaldigit.
In thesecond test case, after we perform the two operations and split the array into 2,500,000 groups of 4 bits,thefirsttwo
groupswill have the state 0011. This represents the hexadecimal digit '3'. All the other groups will have allthe 4bitsunset
representing'0'hexadecimaldigit.

q2
smallestrectangle

You are given a rectangular grid with 2 rows and N columns. The top row is labeled 1 and the bottom row islabeled2.The
columnsarelabeledfrom1toNinincreasingorder.Eachcellinthegridcontainsasinglecharacter.
Consider a hamiltonian walk in this grid. Meaning, pick a starting cell, say (i,j), and consider a path that starts from (i,j) and
goes through every cell in the grid exactly once. Note that you can only walk to adjacent cells, or cells that you sharea
common edge with. There may be several such paths. Let us concatenate the characters in the order in which thecellsare
visitedduringawalk.Thestringformedcanbecalledthestringforthewalk.
Among all the possible walks, and their respective strings, find out the lexicographically smallest string. We know that the
length of thestringsareallthesametobeprecise,2N.Thus,thelexicographicallysmalleststringissimplythe alphabetically
smalleststringifyoucomparethecharactersfromlefttoright.

Input

ThefirstlineofinputcontainsanumberT,thenumberoftestcases.ThenfollowTtest cases.Each testcasecontains3 lines.


ThefirstlinecontainsthenumberN,thenumberofcolumnsinthegrid.Itis wellknownofcoursethatthe grid contains2rows.
Thenext two lines contain the description of the grid in the form of two stringsthestringofNcharactersinrow 1fromleftto
rightandthestringofNcharactersinrow2fromlefttoright,respectively.Eachcharacterwillbealowercaseengishletter.

Output
Output a single line for each test case. The line must contain a string with 2N characters. This string should be the
lexicographicallysmalleststringforsomehamiltonianwalkinthegrid.

Constraints
1T100
1N10

SampleInput
2
3
abc
def
10
ababaaabab
bababababa

SampleOutput
abcfed
aaababababababababab

Explanation
In the first test the possible strings are { abcfed, adebcf, adefcb, badefc, bcfeda, cbadef, cfedab, cfebad,dabcfe, dabefc,
defcba,edabcf,efcbad,fedabc,fcbade,fcbeda}.Thesmalleststringisabcfed.

LinkedIn

LinkedIn@IITB24thNov
SomeMCQs
3Codingquestions

1. Givenanarrayof0sand1s.Youcanchoosetwoindicesiandjandflipallthe
elementsbetweenthem(ie0>1and1>0).Findmaximumsumofthearraywhichcan
beproducedaftertheflip.
egFor[0,1,0,0,1,0],outputis4.flipfromindex2to3.
usekadanesalgo
2.
Findtwonumbersfromanarraywhichsumtoagiventarget.
bruteforcewontwork
3. Situationisthatsomecaterpillarsstartfromthebottomandjumpstothenextleaf.They
eattheleafbeforejumpingtonext.Wearegivenanarraywhichrepresentsjumpsteps
madebycaterpillars.Ifthearrayis[2,4,7],itmeanscaterpillar0willeatleaf2,4,6..
caterpillar2willeatleaf4,8,12..andcaterpillar7willeat7,14,21
0representsground.Calculatethenumberofuneatenleaves.
(
n<=10^9)

LinkedIn@IITM
ExactlysameasIITR.
HostedonHackerrank.

LinkedIn@IITR
Onlinecoding1hr,3Questions
1.Wehavetoimplement
intgetIntComplement(intN)
function,thatwillgivecomplement
(bitwisecomplement.)ofbagiveninteger.Startunsettingfromtheleftmostsetbitofthe
number.0<=N<=50000
Example:
Input:10(1010)
Output:5(0101)

2.Thereare"n"ticketwindowsintherailwaystation.ithwindowhasaiticketsavailable.Price
ofaticketisequaltothenumberofticketsremaininginthatwindowatthattime.When"m"
ticketshavebeensold,what'sthemaximumamountofmoneytherailwaystationcanearn?
exa.n=2,m=4
in2windowavailableticketsare:2,5
2ndwindowsold4ticketsso5+4+3+2=14.

3.Thereisaparticularsequenceonlyusesthenumbers1,2,3,4andnotwoadjacent
numbersarethesame.
Writeaprogramthatgivenn11s,n22s,n33s,n44swilloutputthenumberofsuch
sequencesusingallthesenumbers.
Outputyouranswermodulo1000000007(10^9+7).

LinkedIn@IITG

ExactlysameasIITR

LinkedIn@IITD(dateplease?)
1)searchanumberinabinarysearchtree.return1iffoundand0ifnot.
2)counttotaldistinctsubstringsinastring.N=10^5
3)countdistinctpalindromicsubstringsinastringegS=aabaa.output=5
(a,b,aa,aabaa,aba)
|s|<=5000

Qualcomm

Qualcomm@IITKGP
sameasiitk
Qualcomm@IITK
3sections

A)Aptitude20Questionin20min..questionswerenoteasy..B)CProg.20Questionin20
minmostlyoutputorerrorfindingtype(questionsonOOPSwerealsoasked)
C)ComputerScience20Questionin30Min,comparativelyeasyfromothertwosections.
Tips:
YoustartwithAptisectionandafter20minitautomaticallyredirectsyoutonextsection.
Propertimemanagementisrequired.orAlsotestinterfacehavesomebugsasIfaced.When
youclickonnextsometimeyoumayskip12question.
Questionsforallaresame..butjumbled

QualcommQuestions
Coutputrelatedquestions,functionoverloading,heap,hashing,numberofzerosinn!,process
waandthreadsrelatedquestion

Qualcomm@IITG
PatternSameasIITK

Oracle

Oracle@IITK(AptitudeTest)

4Sections(TotalTime:75Minutes)
1:AnalyticalReasoning(15Question)
2:QuantitativeReasoning(15Questions)
3:VerbalReasoning(10Question)
4:ComputerScience(20Question)
Allthesectionsarefairlyeasy,speciallyquantsandCS.

Oracle@IITM(AptitudeTest)
SameasOracle@IITK

Oracle(Round2Coding)@IITBombay

November52014
Q1)GameofStones,GivenNstacksofdifferentsizes.Twoplayer,onebyonepopsome
valuesfromanychosenstack,ifbothplayersplayoptimallythenprint1ifplayer1willwinthe
Game,print2ifhewilllosetheGame.

Input:N=3{1,1,1}output:1,N=4{1,1,11,11}output:2,N=2{1,100},output:1

Q2)0/1knapsack
Oracle(Round2Coding)@IITMadras
October26th2014
Duration:30mins
Onecodingquestion.
Difficultylevel:frompersontoperson.Ifyou'relucky,youmightgettheeasiestofproblems.
Mostproblemsweredirect*expected*questions.
Platform:mettl
Somequestions:

1.Giveninorder,preordertraversalofaBinaryTreegivepostorder.
2.Rodcuttingproblem.

Oracle@IITKGP(AptitudeTest&CodingTest)
SameasOracle@IITM

Oracle@IITGuwahati(Round2Coding)
About90studentswereshortlistedaftertheMCQroundforallprofiles.Thecodingroundhad
onlyonequestionforeachstudenttobesolvedin30minutes.Theinterfacewasreally
ugly
.
Everyonegotadifferentquestion.Againtheease/difficultyofthequestionispurely
luckbased.BetterpractiseallsortsofstandardDPandgreedyalgorithmicquestions.

SomeQuestions:
1.JobScheduling:Givenstartingandendingtimesofnjobs,Whatisthemaximumno.ofnon
overlappingJobsthatcanbescheduled.Ex
Ifthereare5Jobswithtimeintervals(1,4),(2,3),(3,5),(2,7),(5,8)thenansweris3.
(StartingtimeofonejobandEndingtimeofanotherjobcanbesame).
BothGreedyandDPsolutionswillwork.
2.
StandardNimGame.

Oracle@IITBHU(AptitudeTest&CodingTest)
SameasOracle@IITM

Oracle@IITR(Aptitude&CodingTest)
SameasOracle@IITM

EpicSystems
Doallthesequestions.NoneedtoreadanyotherplacementPaper.Youwillgetallthe
questionshere.

http://www.careercup.com/page?pid=epicsystemsinterviewquestions

EpicSystems@IITD
4sections.
A.SpeedCalculations:2mins10questions,attemptasmanyasucan.
B.Apti:12questions
C.Technical:20questions,basedonsomenewlydefinedlanguage.
sectionB,Cdidnothaveanysectionaltimelimit.Butyouneedtofinishthese3sectionswithin
75mins.Youwillbejudgedonspeedandaccuracy.Sotrytocompleteasfastaspossible.
D.Coding:4questions,2hrs.Butagainyouwilljudgedbasedonspeedandaccuracy. Write
functions.Pseudocodesareallowed.Itslikeaonlineversionofpenandpapercoding.
Questionsofthissectionwasdifferentforeveryone.Iamsharingmyquestions.

#1.Supposeallmonthshave30days.There's12monthsinayear.Februarywouldhave31
daysinaLeapyear.conditionforleapyearisdefinedas(year%40==0)isleap,
(year%200==0)isnotleap,(year%1000==0)isleap.GivenadateasMM/DD/YYYY,findthe
nextLeapDay.
#2.Printmatrixinspiralorder.
#3.Youhavetoprintallpossiblecombinationsofphonenumbers.Thelengthofthenumber
willbegiven.Also3digitswillbegiven,whichcannotbeused.Notwoconsecutivedigits
wouldbesame.Anumbercontaining4wouldalwayshave4inthebeginning.m
#4.Givenanumber,getallpossiblesubstringsusingthedigitsofthisnumberandifthe
productofdigitsinonesubsetissamewiththeanother,thenreturnfalse,elsereturntrue.
e.g.345={3,4,34,45,35,345}
productsare{3,4,5,12,20,15,60}hencetrue
3426={3,4,2,6,34,42,26,....}
product={3,4,2,6,12,8,12,..}hencefalse.(productsof34and26aresame)

Epic@IITR
LogicalReasoning,Aptitude:Seecareercupforquestions.Samequestionswererepeated.
4codingquestions(Questionsforeveryoneweredifferent)mo
1) Tosubtract2numbersgiveninformofarrays.Itshouldhandlealltheoverflow
conditions.
2) Givenamatrix,findthemaximumlengthpath.Givenaindex,youcanmoveonlyright
andbottom,andalsothedifferencebetweentheelementsofthepathshouldbe+1.
3) ImplementBingogame.
4) TicTacToequestion.
5) Searchagivenwordinmatrix.
6) Givenanumber,youcanmultiplyitwithanydigit29,checkifthegeneratednumberis
theanagramofthegivennumber.
7) Givensequenceofkeystrokesofa.
8) In19keypadonekeyisnotworking.Ifsomeoneentersapasswordthennotworking
keywillnotbeentered.Youhavegivenexpectedpasswordandenteredpassword.
Checkthatenteredpasswordisvalidornot
Ex:entered164,expected18684(youneedtotakecareaswhenuenter18684and
164onlybothwillbetakenas164input)
9) Astring'aBlY'issaidtobewellorderedbecausethelettersofthestringoccuroneafter
theotherinthealphabet.Writeafunctionwherethenumberoflettersinthestringare
passedasparameterandallsuchwellorderedstringsarefound.

Epic@IITK

SameformatasIITRandIITD
forspeedquestionsifatoneglanceyoucandoitthendoelseattemptanyoptionandmove
forward(thereisnonegativemarks).Trytolookatasmanyproblemsasyoucan.Youcando
atleast78questions.
forLogicalReasoningandAptidocheckCareercupQuestionsofpreviousyearsand
forprogrammingproblemalso.Many(Ithinkall)ofthequestionsarerepeatedfromthe
previousyears(everyonewillhavedifferentcodingquestions)
.Someofthemare:
1) Generateallwellorderednumbersofgivenlength(digitati+1>digitati)
2) ImplementSolitaireGame
3) Searchagivenwordfromamatrix
4) Givenanarrayoftextprintitincolumnmajorformatwiththetextasreversede.g.
input:Hello
Output:WWH
What
hhe
Where
eal
rtl
eo
5) Givenasequenceofkeystrokesgenerateallpossibletexts

Ebay

Ebay@IIT(BHU)
SectionA

HorribleQuant
Aptitude20questionsin30minutes.Godknowswhatwasthat!!Mostofuscouldsolvehardly
78outofit.

SectionB
Pen&PaperCoding
Easy

Ebay@IITD
SectionA
Pen&PaperCoding:anyoneoutoftwoquestionsin30mins.
Level:Easy

1.Printingastringinwavelikepattern.Ifthecurrentcharacterisgreaterthan(azorder)thatof
previouscharacterthenprintitabove,ifitislessthancurrentthenprintbelowandifitsequal
theninsameline.
e.g.
I/P:abcbd
O/P:(thesedashesindicatesspaces)
cd
bb
a
2.Replacethegivensubstringwithsomeothersubstringinastring.
I/P:SUNDAY,replaceSUwithMO
MONDAY

what will be answer, if I/P SUUNAP, replace SU with MS ??


on first replacement, ans is MSUNAP, but it again contain SU, So do we need only one
iteration, are something like, final answer must not have any substring of SU ??

Ithinkonlyonetimereplacementisenough.

SectionB
Onlineaptitude,20questions,30mins.+1forcorrectanswer,0.25forwrong.
DItimeconsumingtediouscalculations,
LogicalHorrible!
QuantMediumbuttimeconsuming.
Wedidn'tfindmanypeopledoingmorethan1012outof20.

Ebay@IITKGP
Formatsameasabove.
Codingquestions
Q1

Youweregivenalistofstringswhicharecorrectwords.
eg.iswhybookgoodballbatthis
andasentencewithmisspelledwords:
Thsisagodbal.
Onehastocreatethecorrectsentence:
Thisisagoodball.

Thoughitwasntmentioned,itcanprobablybeassumedthatcorrectwordofmisspelledword
ingivensentenceexistsinthegivenlist.

Q2
Printallsubstringsofagivenstring.(Removepossibleduplicatesalthoughitwasntexplicitly
mentioned).
forexampleinputabc
output
a
ab
abc
b
bc
c

Ebay@IITM,November5th
eBay@IITM
Penandpapercodingquestionattemptoneoutof2,30minutes
(1)W,i.e.theorderisQWERTYUIOPASDFGHJKLZXCVBNM
Input:Stringswithonlyuppercase
letters,oneoneachline,thelastlinewillcontaina"."
Output:Thestringsinqwertysortedorder
Example(Idon'tremembertheexactexample,soI'mcreatingmyowntestcase:P)
Input:
APPLE
TRACK
CAT
TRACTOR
QUEEN2
.

Output:
QUEEN
T0RACTOR
TRACK
APPLE
CAT
(2)Giventhesequence3,4,33,34,43,44,333,334,343,...andanumber'n',printthenth
numberinthissequence
Thesecondpartwasanonlineaptitudetestfor30minutes.Thequestionswerelongandthe
calculationsweretedious,similartowhatothers(IITD)havestatedbefore.

BrowserStack(2round)
@IITBHU

Considerthefollowingseries:
A:=1
B:=A*2+2
C:=B*2+3andsoon...
Writeaprogramthat:
outputsthenumbercorrespondingtoagivenletter
givenastringofletterslike'GREP',computesthesumofthenumberscorresponding
toallthelettersinthestring(i.e.,G+R+E+P),asgivenbytheaboveseriesand
givenalargenumber(thatwouldfitintoastandard32bitinteger),findstheshortest
stringofletterscorrespondingtoit.
Youmayuseagreedyapproachforthelastpart.Computethevaluesofthenumbers
correspondingtolettersasandwhenrequiredandDONOTprecomputebeforehandandstore
theminadatastructure.

Youmayattemptthisprobleminanyprogramminglanguage.

2ndquestion
Theprogramwillbegivenafoldernamed(optional,ifnotpassedassumecwd).Theprogramwillprint
somethinglikethis:

$tree
.
|README.md
|closure
||currencySymbols.js

|e2e
||i18ne2e.js
||localeTest_cs.html
|generate.sh
|runtests.sh
|spec
||closureI18nExtractorSpec.js
||converterSpec.js
|src
||closureI18nExtractor.js
||closureSlurper.js
||converter.js

4directories,10files

BrowserStack
@IITB

BrowserStack...... TESTQUESTIONSIITB@27OCT
1.)
Question:Youjoinacompanywhichusesalegacycommandlineprogram.
Thisprogramwhengivenaninputlikethis:abcdefghi
Spitsoutanoutputlikethis:abcfihgde
+
Sourcecodeofthisprogramislonglostandonlythebinary2remains.Youmanagerhas
askedyoudeterminethelogicandwritethisprogram,inacomputerlanguagethatyouprefer,
sothatsourcecodeoftheprogramisinthecontrolofthecompany.
SampleInput(PlaintextLink)
abc
def
g1920
SampleOutput(PlaintextLink)
abcf2019gde
==========================================================
2+.)
Jsonparseplusseriescomputation
Max.Score20
EvaluateanexpressiongiveninanJSONformat.Keyswillbe:Exprcontainstheentire
expressionElemcontainsthedigit,Sum,Prodcontainstwoormorekeyswhoseevaluation
needstobesummedormultiplied,respectively,Subwillcontaintwokeysormore,wherethe

secondkeyonwardswillhavetobesubtractedfromthefirstoneDivwillcontaintwokeysin
whichthefirstkeywillneedtobedividedbythesecond
SampleInput(PlaintextLink)
{
"expr":{
"sum":{
"elem":[
"4",
"6",
"7",
"3"
]
}
}
}
SampleOutput(PintextLink)la
20
Explanation
Input:Willbejsonfilethroughstandardinput.expressionwillbegivenasvalueofexprkey,as
showninexample
Output:Youneedtoprinttheresultofevaluatedexpression

Browserstack:@IITR
12thOctober2014

Onlinecoding3hrs
2questions
20markseach
Problem1:
WriteaprogramwhichtakesJSONasinputandgivesprettifiedJSON
a)YouneedtoreadJSONfromSTDIN.InputgivesonelineofuglifiedJSON.
b)OutputshouldbeformattedJSON.
GiventwoJSONobjects,findthevaluesoffields.whosevaluesaredifferent.
Eg.Input
{"Geeks":"Test1","Are":"hey","Cool":"yeah"}
{"Geeks":"Test1","Are":"20","Cool":['B','C']}

Answershouldbeasfollows..

Ans:Are:Cool

Problem2:l
GivenastringandaRegularExpressionmeanasfollows:
.2occurrencesofthepreviouscharacter,+4occurrencesofpreviouscharacterpattern,
givethenumberofthetimesthepatternoccursinthestring.RegExsymbolser,*morethan
5occurrencesofthepreviouscharacter
SampleInput(PlaintextLink)
5
aaaaaannndnnnnnnfffhfhhgjjjwkkkllclc
a.
n+
a*
an.
a.d.
SampleOutput(PlaintextLink)
5
3
2
1
0

Browserstack:@IITD
Problem1:
Givenanumbern,printthesumofdigitsinn!.(ncanbelarge)

Problem2:
SameasIITR

Browserstack:@IITBHU

IITBHUbrowserstackwrittenroundquestions.Duration:3hours,Platform:HackerEarth

1.Givenapieceofcode,thetaskwastoremoveallthecommentsfromthecode.
Eg.Input
intmain(){
//thisisacomment
inti=1

/*
somemore
comments
*/
cout<<i
cout<<endl//thisisfornewline
return0
//lastone
}
Output:
intmain(){
inti=1
cout<<i
cout<<endl
return0
}

2.
JSONparsingsameasIITR

Browserstack:@IITG

1.
GivenHTMLCodewithtags,insertindentationbasedonopeningandclosingoftags.
ExampleInput:
<FIRST>
<SECOND>
<THIRD>
ThisisthirdW
<FOURTH>
<FIFTH>
Thisisfifth
</FIFTH>
</FOURTH>
</THIRD>
sampleline
</SECOND>
</FIRST>

output:
%FIRST
%SECOND
%THIRD
Thisisthird
%FOURTH
%FIFTH
Thisisfifth
sampleline

(eachtabconsistsoftwospaces,i.e.tab=).

2.
Nibonaccinumbersaredefinedas
f(x)=0forallx<=0
f(x)=1forx=1andx=2
f(x)=f(x1)+f(x2)+f(x3)++f(xn)forx>=2

Thatis,foragivennthesequenceislike0,1,1,2,...
Example,forn=3,thesequenceis0,1,1,2,4,7,13,
andn=4,thesequenceis0,1,1,2,4,8,15,.

Now,considering0and1alsoaspowersof2,foragivenn,findtheleastnumberofthe
sequencewhichisnotapowerof2modulo10^9+7(1000000007)
2<=n<=1000000
Example:
Inputn=2,output=3
Inputn=7,output=127
(Bycarefullyobserving,theanswerisnothingbut2^n1.Themainproblemboiled
downtofindingthe2powerforverylargenumbersinlesstime)

Walmart

Walmart@IITRSep30

12ObjectiveQuestions(GATElike)2CodingquestionsOS,GraphTheory,Automata,SQL,
Algorithm

HostedonHackerRank

Duetoslowinternetconnectivity,wewereaskedtosolvethequestionsonpaperwhichwillbe
manuallychecked.
1)QuestionbasedonOptimalmergepatternproblemgivenlistofsortedfileswehavetofind
outnumberofcomparisonsinoptimalworstcase.
2)46bitvirtualaddress,8gbram,pagesize8KB,Eachpageentrysize4bytes.Wehaveto
findoutmin.numberofpagelevels(ans3)
3)Givenanindexofanelement,Fromheapwehavetodeletethatelement,theyaskedtime
complexityforthat
4)Numberofcomparisonsrequiredinmergesorttomergensortedarrays
5)Reversingeachwordinastring.Whatisthecomplexity?
6)Thevaluesofa,b,canddliesbetween[1,12].Thereisanedgebetween(a,b)and(c,d),only
ifmod(ac)<=1andmod(bd)<=1.Counttotalnumberofedgesinthegraph.
7)slidingwindowprotocolnumerical
8)Acodesnippetwasgiven.Whatdoestheabovecodecalculate?Ans:successorofanode
inatree
9)Thereare8verticesinapolygon.Probabilityofhavinganedgebetweenanytwoverticesis
0.5.Calculateexpectednumberofunorderedtriangles.
10)fewregularexpressionsweregivenchoosewhichsatisfylanguageover(a,b),contains
atleast2a.(3optionswerepossibleforthis)
11)Wehavetofindthetopfivemoviedirectorsfromadatabase.Whichofthefollowingquery
givesthecorrectoutput?
12)Samequestionisgivenhere
www.geeksforgeeks.org/minimumnumberofjumpstoreachendofagivenarray/
Codingquestion
Alockhasnbuttons.
Itopensifonepushesthebuttonsinaspecificorder.Ifonepressedthecorrectbutton,it
remainsinpressedstate(ON).IfonepushesawrongbuttonalltheONbuttonsturntoOFF
stateandtheuserhastopushthebuttonsagain.
OurheroAmitdoesn'tknowthecombinationsohetriesrandomcombinationstoopenthe
lock.Intheworstcasehowmanypresbuttonses(pressesnotsequencesofbuttons)doeshe
havetodotoopenthelock?Foreg.Ifthereare3buttonsandcorrectcombinationis231.
Amitpressesthissequencetoreachthecorrectorder1,3,2,1,2,3,1

Walmart@IITBHUNov13

CodingQuestions
1) Findingthenoofconnectedcomponentsinagridbasedon4connectivity.
http://www.geeksforgeeks.org/findnumberofislands/
1) Aknightisplacedonan8x8chessboardatpositionx,y.Whatistheprobabilitythatit
willstayinsidetheboardafternmoves.

AptitudeQuestions
1) (AquestionbasedonBayestheorem)
2) Offbyoneerroriswhichtypeoferrora)tb)Logicc)Executiond)Testing
3) 100kgmilkwith99%waterisboiledtillithas98%water.Whatisitsmassnow?
4) Microbeshavepotency,toxicity&growthvalues.Thesevaluesofdifferentmicrobesare
plottblechart.Findthemostdangerousmicrobe.
5) (AquestiononpropertiesofNPcompleteness.)
6) HTTPSuseswhichprotocolinthetransportlayer?
7) BehaviourofagivenCsnippet(withmemset&strncat)
8) P:Acollectionofsandgrainsisaheapofsandifnoofgrains>10000000.
Q:Removingasinglegrainfromaheapofsandstillgivesaheapofsand.
P,Q=>Asinglegrainisaheapofsand.Whatistheproblemwiththisargument?
9) (dontremember..willaddlater)
10)(dontremember..willaddlater)

Walmart@IITKGP(Developer)(30thNovember)

10simpleMCQquestions.
2codingquestion.
TotalTimeduration:1Hr30minutes
STOD
1)Startfromgrid(1,1).Youcanmoveinthefollowingmanner(x,x+y)or(x+y,y).Coordinate
ofdestinationnode(m,n)given.Printthesmallestno.ofmovestoreachdestination.Ifnot
possibleprint1.
2.commaseparated3stringx,y,zaregiven.Ifxandyaresubsequencezandsumoflength
ofalphabetsofx&yisequaltolengthofalphabetsofz,thenprintYESelseNO.
example:
HELLOWORLDHELLOWORLD
YES
SOSOAPSOAP
NO


Samsung
SamsungIndia(R&D)@IITM,19thOctober2014
Round1:60mins
Verbal:20questionsif(text[k]=='s')
Analytical:20questions
Math:20questions
Tip:AttempttheMathpartfirstandVerbalthelast.
ShortlistbasedonscoreinRound1

Round2:
Onlinecodinground1hr
Questionsweredifferentfordifferentpeople.Questionscollectedfromalimitedpoolof
questionsandjumbledforeveryone.
3questionsforeachstudent.1questionfor8pointsand2for5pointseach.
1.Givenazeroormoreoccurrencesofthedigit0.[5points]string,printthenumberof
occurrencesof1[0]*1where*denotes
Input:10011abc10000001
Output:3

2.Givenastrings1removealloccurrencesofthestrings2instrings1andalsoremoveall
occurrencesofstrings2afterremovalofs2ins1andsoon..andreturnthestringobtained
aftersuchremovals.[5points]
Example:s1="qwewerrty"s2="wer"
Output:qty
(Onthefirstremovalofweritbecomesqwerty.Onremovalagainnowqty.Nothingtoremove
now.)

3.Questionhadsomerobotandstorybuildupbuttheessenceisthis:
Youaregivenanmxngrid,where(0,0)referstopmostleftpositionand(m1,n1)thebottom
mostright.Thegridisfilledwithones.Allpositionsinthegridthatareblockedarefilledwith
zeros.Youaregiventhisgridandareassuredthatthereexistsatleastonepathfrom(0,0)to
(m1,n1).Findtheminimumdistanceofthepathfrom(0,0)to(m1,n1)giventhatyouare
allowedtomoveonlyvertically,horizontallyanddiagonally.[8points]
4.Giventwolinkedlists,whereeachnodeofalistcontainstheexponentsandcoefficientsofa
polynomial(indecreasingorderofexponents,zerocoefficientsdon'thavenodesassociated

withthem),performmultiplicationofthetwopolynomialsandreturnalinkedlistwiththeresult
(conditionssimilartotheinputdecreasingorderofexponents,termswithzerocoefficients
shouldnotbepresentinthelinkedlist)[5points]

5.Givenawordwithuniquelowercasecharacters,returnitsrankinadictionarythatconsists
onlyofwordsthatareanagramsofthegivenword.
Eg:"take":6wordsstartwith'a',6with'e',6with'k',1with'tae',andfinally"take",soitsrank
is6+6+6+1+1=20.[8points]
2Rounds:

CODENATION:2014IITD


continued

2222

InMobi@IITK
InMobi25TechnicalMCQs...
25TechnicalMCQs
2CodingQuestions:

1.http://www.geeksforgeeks.org/maximumsumpathacrosstwo.../

2.
SuperKnightProblem:
GivenSizeofchessboardandsourceposition,destinationpositionandlenghtk.Findnumber
ofpathsfromsourcetodestinationingivenchessboardhavingexactlyklength.Knightsmoves
aredefined

or
2.
An*nchessboardisgivenandaspecialplayerwhichcanmovelikekingandknight..
total16possibilities..
initialandendingordinatesaregivenandnumberofmoves.Youhavetofindhowmanyways
toreachtotheendbyusingexactlygivennumberofmoves.

InMobi@IITR
Date01/11/2014

Q1.EvaluatetheexpressionEwitheachoperationsurroundedbyroundbrackets.
Eg.(4+((5*8)+556))and((20/5)5)
Note:Therewontbeanysubexpressionwhichdoesnthavebracketssurroundingit.Also
thereinthisquestionthenumberofcasesinatestcasewasnotgiven,soyoullhavetoreadit
tillendoffill.Manystudentshaddifficultytofigurethatout.
TrickSolution
:Inpythonifyoutakethestringasthisasinputanduseprints,itllautomatically
evaluateitforyou.AndforinputputreadstatementintryblockandcatchtheexceptionEOF.

Q2.Thereareelectionsintown.Eachcandidatehasbeenvoted.A[1n]isthearraywhere
A[i]denotesthenumberofvotesfortheithcandidate.ThisarrayA[]issortedindescending
orderwithtiesbrokenbyincreasingindices.Youcanincreasethevotesforanycandidateand
alsoyouhaveadesirelistforthecandidate.Rank[1n]denotestherankofthecandidatethat
youwantthecandidatetobeinthatpositionwhere1denotesyoudontcareforhim.Findthe
minimumnumberofvotesaddedbyyoutogettherankofthecandidatesasinRankarray.
Eg.A[]={10,8,6,4,3}

Rank={0,2,1,3,1}

Ans3(Increase6to9)
Eg.A[]={10,100,40,15,15}

Rank[]={4,0,1,3,2}

Ans1(tiebreakercase)

Nutanix@IITD

QuestionsofNutanixinIITDwere
1.Giveninorderandpreordertraversalofabinarytree,printthepostordertraversalofthe
tree.

2.Amazewasgivenwithstartpointandanendpoint.Cellscouldbeeitheroftheform"."(can
bevisited)or"*"(cannotbevisited).Findtheminimumcostrequiredtogofromstarttoend.
Theremightbecellsmarkedwithuppercasealphabetsaswell(calledportals).Eachportalhas
anentryanexitpoint.Wecanusetheportalstojumpfromonepositiontotheother.

@...
..#.

A..*
*A..

@A......A#

Nutanix@IITBHU
2Questions75minutes
1. Giveninorderandpostordertraversalofabinarytree,printtheverticalordertraversal
ofthetree
2. ReadfromstdintillEOFandstorethewordswithallcapitallettersinatableindexedby
thelengthofthestring.Printthetableinthegivenformat.
Dontrepeatwords,forwordswithsamelengthprintinsameorderasininput.
Separatorneednotbespace,itcanbeanynonalphabeticcharacter.

Loremipsumdolorsit/AMET,consecteturadipiscingelit,sedDOeiusmod
temporincididuntutlaboreetdoloremagnaALIQUA.Utenimadminim
veniam,QUISnostrudexercitationULLAMCOlaborisnisiutaliquipexea

output
2:DO
4:AMET,QUIS
6:ALIQUA
7:
ULLAMCO

VISA@IITB

VisaInc.@IITB.Onlinecoding+MCQ.75Minutes.
========
AssessmentComposition:
1.CodingSkills:2QuestionsVerysimpleproblems30markstotal
2.Programming:10QuestionsSimpleJavaQuestions
Accessmodifiers,inlinefunction,Redblacktree,heap
3.MachineLearningHadoopMCQ:6Questions
Youcan'tanswerasinglequestionifML/BigDataisremotelandforyou.
4.NetworkingMCQ:6Questions
Againbasics.Datalayerquestions.IPclassbasicquestion,fieldsinethernetheader.
5.OperatingSystem:6Questions
Memorymanagementmostly
6.Infrastructure:6Questions
Reallifescenariosserverclientquestions.
7.ApplicationSecurity:6Questions
TypicalNetworkSecurityquestions.DiffieHellman,c
EachMCQ1mark.Nonegativemarking.
Allthebest.

PoolOfQuestions:

1.
http://www.geeksforgeeks.org/largestsumcontiguoussubarray/

2.givenpreorder,inorder,calculatepostorder.

^(Q9:Whendoesaplayerwin??????)

VISA@IITG
November12,2014
OnlineCodingQuestions:
Twoquestionsselectedfromapool.
1.
TheChefhastopreparemaximumnumberofdishesinthegiventime.
Input:TotaltimeT,numberofdishesonthemenu(sizeofthearrays)n,anarraycook[]
wherecook[i]isthetimerequiredtopreparetheithdish,anarraywait[]where
abs(wait[x]wait[y])istheInput:N(0<N<=2000),Output:x,wherexisamultipleofNand
sumOfDigits(x)==N
2.
Giveninorderandpreordertraversalofabinarytree,printthepostordertraversal
Othersectionsasstatedabove.

Amazon

@IITG(4.11.14)
20MCQ,2Coding90minsPlatformHackerrank
MCQs:
1.
Whichcharactercanbeusedinvariablename:|,*,,_Ans(_)
2.
ComplexityofsortingnstringofnlengthinlexicographicorderusingMergeSortAns:
O(n^2logn)
3.
BubbleSortComplexityRelated:Ans:400
4.
#include:Preprocessing
5.
Npointsareplacedinacircleandshootoutalternateuntilend,whichdatastructureis
usedforimplementation.(Ans:CircularLinkedList)
6.
APriorityQueueisimplementedasaMaxHeap.Initially,ithas5elements.The
levelordertraversaloftheheapisgivenbelow:10,8,5,3,2Twonewelements"1"and
"7"areinsertedintheheapinthatorder.Thelevelordertraversaloftheheapafterthe
insertionoftheelementsis:
(a)10,8,7,5,3,2,1
(b)10,8,7,2,3,1,5
(c)10,8,7,1,2,3,5
(d)10,8,7,3,2,1,5(ans)

7.

Outputofthiscodesnippet
#include<stdio.h>
intmain()
{

intnum[]={1,4,8,12,16}
int*p=num
int*q=num+2
inti=*p++
printf("%d%d%d\n",i,*p,*q)
}
ans148

8.

Output:
#include<stdio.h>
intmain(){
inti=2+3,4>3,7
printf(%d,i)
return0
}
anscompilationerror
CodingQuestions:
1.
3numbersaregivenaslinkedlist.Eachnoderepresentsadigitofanumberstarting
fromleft.Addthethreeno.sandreturntheresultinalinkedlist.
2.
Sortalinkedlistcontainingzeros,onesandtwos.
(
http://www.geeksforgeeks.org/sortalinkedlistof0s1sor2s/
)

@IITM(30.10.14)
20MCQ,2Coding90minsPlatformHackerrank
MCQs:
Outputofcodesnippet,OS,DBMSbasics,Complexityestimation,basicdiscretemath.Gate
typequestions.(Maybethoseweregatequestions.I'mnotsure.)
CodingQ1:
PhoneKeypad=>Givenpresseddigits,printallpossiblestringsthatyoucangenerate.
CodingQ2:
EvaluateExpression=>4operatorsinorderofprecedence:(%,*,+,)associativityisleftto
right.Ex:2+43%4*3=11


@IITKGP

(03.11.14)
20MCQ(negativemarkingisthere,allquestionsarebasedonOSTimeComplexitiesDS,
Programming)+2CodingQuestions
oneonlyneedtowritefunctions
1)gEX{a,b}length=Givensetofcharactersfindallpossiblestringswithlengthkusingset
ofcharacters
output:aaa,aab,aba,abb,baa,bab,bba,bbb

2)LongestZigZagsubsequence
Asequenceofnumbersiscalledazigzagsequenceifthedifferencesbetweensuccessive
numbersstrictlyalternatebetweenpositiveandnegative.Thefirstdifference(ifoneexists)
maybeeitherpositiveornegative.Asequencewithfewerthantwoelementsistriviallya
zigzagsequence.
Forexample,1,7,4,9,2,5isazigzagsequencebecausethedifferences(6,3,5,7,3)are
alternatelypositiveandnegative.Incontrast,1,4,7,2,5and1,7,4,5,5arenotzigzag
sequences,thefirstbecauseitsfirsttwodifferencesarepositiveandthesecondbecauseits
lastdifferenceiszero.
Givenasequenceofintegers,sequence,returnthelengthofthelongestsubsequenceof
sequencethatisazigzagsequence.Asubsequenceisobtainedbydeletingsomenumberof
elements(possiblyzero)fromtheoriginalsequence,0leavingtheremainingelementsintheir
originalorder.
ex:1,7,4,9,2,5output=6

@IITG

(04.11.14)
20MCQ(negativemarkingisthere,allquestionsarebasedonOSTimeComplexitiesDS,
Programming)Codingquestionswereextremelyeasy.
1.
http://www.geeksforgeeks.org/sortalinkedlistof0s1sor2s/
2.
Thefollowingquestionextendedtothreeinputs.
http://www.geeksforgeeks.org/sumoftwolinkedlists/

GoldmanSachs

@IITKGPsame@IITMsame@IITBsame@IITRsame@IITBHUsame@IITGsame@IITD
@IITKsame

Objective
:75mins(10+10+5)qs
1.
2dgraphwithNvertices,EedgesandFfaces(regionboundedby>3edgeswithno
edgecrossingacrossit).GivenNE+F=2foracertaingraphof10vertices,find
maximumnumberofedges
2.
Splittheverticesofagraphintotwosets,witheachhavingequalprobabilityofgoingin
eitherset.Findexpectednumberofedgesconnectingthetwosets.
3.
GivenamatrixA(2x2),findA^10
4.
GivenAsatisfyingaproperty,doesithaverealeigenvalues.Therewere3suchAsand
theconstraintineachcasewas:1)A^2+I=02)(A3I)^2=03)A+I=0
5.
GivenasetS={1,2,3,4,5,6,7,8,9},howmanyevensumsubsets
6.
Whatistheprobabilityofselecting10numberfromthesetoffirst18naturalnumbers
suchthatselectednumbersareconsecutiveincreasing
7.
Findamountofwatertrappedbetweenwalls.E.g:1213>1watertrappedbetween
1,2and2lengthbetween2,3

Subjective:
90mins(someonepleaseputanswers)
1.
Snakeandladdergameminimumnumberofmoves(3pagesweregiventowriteans)
2.
Verticalviewoftree
3.
Givenbinarytree,printpairofnodeswhoseswapmaketreeasbst
4.
t1<=3t2questioninshortestpathingraphsrepeatedfromlastyear
5.
rectangle6x12.provethatif7pointsarechosenrandomlyinit,distbetweenatleast2
points<=5//SolutionbyPigeonholePrinciple
6.
ImplementLRucacheinwhichgetandsetcanbedoneinatmaxO(logn)andalso
writehowtoiteratecache
7.
b1,b2,b3.bnblackballs,w1,w2,w3.wmwhiteballsinurn.pick1by1untilall
blackarepicked.probabilityofkwhiteballsremaininginurn=?probabilityofwjwhite
ballremaininginurn=?expectednumberofballsremaininginurn=?(dontexactly
remembertheq)

FacebookQuestionsIITB
Hackerrank,1.30hrs

1.

2.

AmatrixisgivenwhereeachcellhasYorN.Yimpliesthereisgrassonit.
Connectedcellsofgrassisfield(2cellsconnectediftheyshareanedge).Inafieldonly
onesheepcaneatgrass.Findnumberofwaysinwhichevensheepcaneat.
(Note:0iseven,nC0+nC2+nC4+=2^n1,Usebfs/dfsandthisformulatoavoid
timeout)
Minimuminsertionsrequiredtoconvertstringtoplindrome.(Betterthann^2requiredfor
passingalltestcase)

FacebookQuestionIITKGP
Hackerrank,1.30hrs
Onlyonequestionwasasked!!!:D
Twointegersn,karegivens.t.1<k<2^n.Findthekthrankedbinarystringoflengthnoutofall
thepossiblestringssuchthattheyaresortedaccordingtothefollowingcriteria:
lowernumberof1sinthebinaryrepresentation=>lowerrank
incaseofties,numberwithlowervalue(decimal)getslowerrank.

e.g.n=3,k=5
output=011
how?
allpossiblebinarystringsoflength3insortedorderare:
000,001,010,100,011,101,110,111
printthe5thstring.:)

Anyhelponthisproblem?
Yes,here:O(n^2)solution=>
http://code.hackerearth.com/f29854g

Citicorp@IITM
Profile:BusinessAnalytics(Mumbai)
Pen&Paper,50Minutes
Therewere45DatasufficiencyQuestions.

CitiCorp@IITKGP
(Analystprofile):
Writtentest,45minutes
15Quant,5DI,5DataSufficiency,2casestudies
casestudy1wasonExpectedProbability
IonlyrecallCasestudy2whichis
arectanglehousewhoselength30feetandwidth15feet.Acowistiedtothecornerofhouse
atadistanceof12feetwithalengthofrope21feet.grassisthereoutsidethehouse.
Questionwasfindouttheareawhichisavailabletocowtoeatthegrass.

Ansitwouldconsistofthreeareas[3.14*21*21/2+3.14*9*9/4+3.14*3*3/4]=3.14*243
nonono
CitiGlobalDecisionManagementIITK:ExactlysameasKgp

UnBxd@IITR
Pen&PaperCoding:duration2hr
1.
Givenrand_10()function

whichgeneratenumberbetween09,implement
rand_100functionwhichgeneratenumberbetween099
2.writeprogramtoevaluategiveninfixexpression
3.givenatreehaving
left,right,randompointer(whichpointtoanyrandomnode)writelevelorder
traversal(withoutanyextraspace)
4.UaregivenarrayofNstringsoflengthLfindminimumlengthstringHwhich
haveKstrings(fromarrayofstrings).
inputfirstlinecontainN,L,K
nextNlinecontainNstring.

CitiCorp(ITanalyst)atatIITD:
25CSquestionsin35mins(easy,includedgraphs,datastructures,sorting
algorithms)
16Quantquestionsin16mins(veryeasy,mostlyincludingprofitanddiscount,
timespeeddistance,calculations)

LogicalReasoningquestionsdependedonwhatlanguageyouhadchosenfor
coding.NotincludedinJAVAtest.

Codingquestions(2outofthefollowing):
1. givenanintmatrix,rotateitby90degreesleftorrightdependinguponflag
variable.
2. givenanintmatrix,finditsgrammatrix.

3.

4.

implementFIFOpagingtechnique,descriptionwasgiveninquestion
implementNRUdo

ClearTaxMTS:IITGuwahati

16questions(12objective+4programming)

MCQs:relatingtoC/C++,Java,Javascriptoutputquestions
Alsosomebasicaptitudequestions.

Programming:
1) Kdifferencepairsinanarray(arraycontainsalldistinctintegers)
2) Givenaarrayofnumberseg:a=[2,3,4],andaintegerN,findthenumberof
numbersHwhicharenotmultiplesofofa[i]intherange1N.Thisproblem
wasstatedinadifferentwayusinggrasshoppersleapingindistancesofj,
eatingleavesj,2j,3j,....
3) Givenatreein(parent,child)pairformprintthesform
4) Giventhenumberofcitiesandcompaniesalongwiththepopulationof
eachcity,minimizethemaximumnumberofpeopleworkinginacompany.
Thereweretwoconstrains:Apersoncannottraveltoanothercitytowork,
andeachcityhadatleastonecompany.

TEXASINSTRUMENTS(IITM)
Onlinetest
Aptitude(almostsameasmostoftheothercompanieslikeIntelandQualcomm)
+Technical(mostlyanalog)

Interview(TheyaregenerallyonlyinterestedinAnalog)
VerybasicRCquestionswereasked.SomeOpAmpandfeedbackquestions
werealsoasked.
1. Given1storderRCplotvoltageacrosscapacitorforstepinput.Whatisthe
timeconstant.
2. Sameas1stquestionwithextracapacitorparallelwiththeresistor.
3. Sameas2ndquestionwithextraresistorinseries/parallelwiththe
capacitor.
4. Findnumberofpolesandzeroesgivenacircuit.
5. Generalcharacteristicsoffeedbacknetwork.
6. OpAmpbasics
7. Explainanalogrelatedprojects(Dontmessthisup.Youaresupposedto
knowwhatallyoudidinyourproject)

HRInterview
Justaformality.Butpleasedontmentionyourhigherstudyplans.

Você também pode gostar