0% found this document useful (0 votes)
55 views21 pages

Ds Questions

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
55 views21 pages

Ds Questions

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 21
‘Top 15 Data Structures and Algorithm Interview Questions Answers for Java Programmer Data structures and algorithm questions are an important part of any programming jb interview, be ita Java interview, a C++ interview, or any other programming language. Since data structures are core programming concepts, i's mandatory for all programmers, to know basic data structures like the stack, linked list, queue, array, tree, and graph. Though trees and graphs are on the tougher side, I stil see programmers get familiar wll ll these. Any list of programming job interview questions is incomplete without questions from data structures and algorithms. Similarly, while going on questions from data structure you may get some programming exercise as well e.g. swapping numbers without temp variable. The linked list and array are favorite topics in any data structure interview, questions like reversing a linked list, traversing a linked list, or deleting nodes from the linked list, which involves algorithm and data structures that are quite common. ‘Similarly, finding duplicates in an array, finding missing numbers, soriing arrays are very popular. You can also expect questions from the stack, queue, array, linked list, tree, graph, and hash table are most common in any data structure interview. In this tutorial, we will see a couple of data structure questions answers from these topics. Let us know if you have any interesting questions from data structures and algorithms, which you faced during any Java interviews, By the way, you also need some understanding of the basic data structure before solving these questions. There is no point in attempting these questions if you don't know how to access elements from an array or linked list or can't even cade them using the programming language of your choice. In such cases, i's better to revise fundamentals by joining a comprehensive online course like Data Structures and Algorithms: Deep Dive Using Java. This way you can get the best of both worlds, you will lear data structure and algorithms and also prepare for the interview. 15 Data Structures and Algorithm Interview Questions for Java Programmers This is a combined list of questions from the various data structures e.g. array, linked list, stack, or queue. It includes some coding questions as well, which gel with data structures. Question 1: How to find the middle element of the linked list in one pass? (One of the most popular questions from data structures and algorithms is mostly asked in a telephonic interview. Since many programmers know that, in order to find the length of a linked list we need to first traverse through the linked list till we find the last node, which is pointing to null, and then in the second pass we can find a middle element by traversing only half of length They get confused when the interviewer asks him to do the same job in one pass i.e. without traversing the linked list again. In order to find the middle element of the linked list in one pass, you need to maintain two-pointer, one increment at each node while the other increments after two nodes at a time, having this arrangement, when the first pointer reaches the end, the second pointer will point toa middle element of the linked list. See this trick to find the middle element ofthe linked lst in a single pass for more details. Question 2: How to find if a linked list has a loop? This question has a bit of similarity with the earlier algorithm and data structure interview question. | mean we can use two pointer approach to solve this problem. If we maintain two pointers, and we increment one pointer after processing two nodes and the other after processing every node, we are likely to find a situation where both the pointers will be pointing to the same node. This will only happen if a linked list has @ loop or cycle. You can check my article linked list with cycles for more details. Get new posts by email: Enter your email Subscribe Followors (4972) ex BosBLnaAR bY Bese Question 3: How to find the third element from the end in a linked list in one pass? This is another frequently asked linked list interview question. This question is exactly similar to finding the middle element of a linked lst in a single pass. It we apply the same trick of maintaining two-pointers and increment another pointer, when first has moved up to the 3rd element, then when the first pointer reaches the tend of the linked list, the second pointer willbe pointing to the 3rd element from last ina linked lst. ‘Sometimes, interviewers can also generalize this problem and ask him to find the kth element from the tail, end, or last. Just use the same logic, replace 3 with k and you can solve the problem. Ifyou want to learn more about the linked list, you can also check out Algorithms - on Pluralsight. Question 4: In an integer array, there is 1 to 100 number, out of one is duplicate, how to find? This Is a rather simple data structure question, especially for this kind of. In this case, you can simply add all numbers stored in an array, and the total sum should be equal to n (n¥2) /2, Now just subtract the actual sum to the expected sum, and that is your duplicate number. Of course, there is a brute force way of checking each number against all other numbers, but that will result in the performance of O(n*2) which is not good. By the way, this trick will not work if an array has multiple duplicates, or it's not numbered forming an arithmetic progression. Here is an example of one way to find a duplicate number in the array. Question 5: How to reverse String in Java? This is one of my favorite questions. Since stz ing is one of the most important types of programming, you expect a lot of question-related to String in any data structure interview. There are many ways to reverse String in Java or any other programming language, and the interviewer will force you to solve this problem by using without API i.e. without using the reverse () method of s: ringBuffer. In the follow-up, he may ask to reverse String using recursion as well. See 3 ways to reverse String in Java to learn to reverse String using both loops and recursion in Java, Question 6: Wi algorithm? have always sent a couple of questions from searching and sorting in data structure interviews. Bubble sort is one of the simplest sorting algorithms but if you ask anyone to implement it on the spot it gives you an opportunity to gauge the programming skills of a candidate. See How to sort an array using Bubble Sor in Java for 2 complete solution to this data structure interview question a Java program to sort an array using the Bubble Sort Question 7: What is the difference between Stack and Queue data structure? One of the classical data structure interviews questions. | guess everyone knows, No? Anyway, the main difference is that Stack is LIFO (Last In First Out) data structure while Queue is a FIFO (First In First Out) data structure. You can further see my arlicle stack vs queue in Java for more details. Blogs Question 8: How do you find duplicates in an array if there is more than one duplicate? (solution) ‘Sometimes this is asked a follow-up question of earlier data structure interview questions, related to finding duplicates in Array. One way of solving this problem is by using a Hashtable or HashMap data structure. You can traverse through the array, and store each number as a key and the number of occurrences as a value. At the end of traversal, you can find all duplicate numbers, for which occurrence is more than one. In Java if a number already exists in HashMap then calling get (index) will retum a number otherwise it retums null. this property can be used to insert or update humbers in tia shttap. Question 9: What is the difference between the Singly Linked List and Doubly Linked List data structure? This is another classical interview question on the data structure, mostly asked on telephonic rounds. The main difference between the singly linked list and the doubly linked list is the ability to traverse. Ina singly linked Iist, a node only points towards the next node, and there is no pointer to the previous node, which means you can not traverse back on a singly linked fist. On the other hand, the doubly linked list maintains two pointers, towards the next and previous node, which allows you to navigate in both directions in any linked list If you are preparing for interviews then I also suggest you learn some essential coding pattems like two points, fast and slow pointers, sliding window, and merge interval which can help you to solve many frequently asked coding problems. Ifyou need a course, | highly recommend Grokking the Coding Interview: Patterns for Coding Questions course on Educative. I's an interactive course where you can try out this pattem in the browser itself, Sliding window -> Slide one element forward Ly 4{a]ele Question 10: Write a Java program to print the Fibonacci series? This is not a data structure question, but a programming one, which many times. appear during data structure interview. Fibonacci series is a mathematical series, where each number is the sum of the previous two numbers €.g. 1,1, 2, 3, 5, 8, 13, 24 ‘An interviewer is often interested in two things, a function that retums an nth number in the Fibonacci series and solving this problem using recursion in Java. Though it’s an easy question, the recursion part often confuses beginners. See this link to find the nth Fibonacci number in Java, Question 11: Write a Java program to check if a number is a palindrome or not? (solution) This is similar to the previous question, not directly related to data structures, but quite popular along with other questions. A number is called palindrome ifthe reverse of the number is equal to the number itself. ‘An interviewer asks to solve this problem without taking help from Java API or any open source library. Anyway, it's a simple question, you can use the division operator (i) and remainder operator (2%) to solve this question. Just remember, the division operator can be used to get rid of the last digit e.g 1234/10 will give you 123, and the modulus operator can give you the last digit e.g. 1234%10 will return 4, By the way, here is a Java program to check if the number is palindrome or not. Question 12: What is a binary search tree? (solution) This is a data structure question from Tree data structures, Binary Search Tree has ‘some special properties lke left nodes contain items whose value is less than root, right subtree contains keys with higher node value than root, and there should not be any duplicates in the tree. ‘Apart from the definition, an interview can ask you to implement a binary search tree in Java, and questions on tree traversal e.g. in otter, preorder, and postorder traversals are quite popular data structure questions. Question 13: How to reverse a linked list using recursion and iteration? (solution) ‘This is another good question on data structures. There are many algorithms to reverse the linked list and you can search for them using google. | am thinking of «writing another blog post to explain the linked list reversal and will share it with you later As one of my readers mentioned, | have already written about it and linked it into the ‘solution link, you can check out my solution but | strongly suggest you try it yourself before looking atthe solution, Question 14: Write a Java program to implement Stack in Java? (solution) You can implement Stack by using an array or linked list. This question expects you to implement a standard method provided by stack data structure e.g. push () and pop (). Both push () and pop () should be happening at top of the stack, which you need to keep track of. I's also good if you can implement utility methods like contains (), istmpty() etc By the way, JDK has @ java.util.Stack class and you can check its code to get an idea, You can also check the Effective Java book, where Josh Bloch has explains how an incorrect implementation of the stack can cause a memory leak in Java. also suggest looking at data structure and algorithm questions on Cracking the Coding Interview book, as this book contains some good questions with proper explanations. That will certainly help you to do better in programming job interviews. (One more suggestion | have to make is whenever you get some time, just read the Introduction to Algorithm by Thomas Gormen, if you have not read it already. This book is the bible of algorithms and IMHO every programmer should read this book. That's all on this list of data structure interview questions and answers. This is tone topic, which is always asked in any programming interview, doesn't matter if you are C, C++, or Java developer, basic knowledge of data structure like an array, inked list, stack, queue, the tree is must to clear any programming interview. Other Data Structure and Algorithms Articles you may like + Top 30 Array Coding Interview Questions with Answers (see here) + How to find a missing number in an array? (answer) + 10 Algorithms Books Every Programmer Should Read (books) + How to compare two arrays in Java? (answer) + 100* Data Structure Coding Problems from Interviews (questions) + How to reverse an array in place in Java? (solution) + Top 15 Data Structure and Algorithm Interview Questions (see here) + Top 20 String coding interview questions (see here) + How to find all pairs whose sum is equal to a given number in Java (solution) + Top 30 linked list coding interview questions (see here) + Top 50 Java Programs from Coding Interviews (see here) + 7 Best courses to learn Data Structure and Algorithms (courses) + 50* Data Structure and Algorithms Problems from Interviews (questions) + How to remove duplicate elements from an array in Java? (solution) + 10 Free Data Structure and Algorithm Courses for Programmers (courses) Thanks a lot for reading this article so far. If you lke these Data Structure and Algorithm Interview questions and answers then please share them with your friends and colleagues. If you have any questions or feedback then please drop a note. P. S. -If you think that your data structure and algorithm skill are not par and you ‘want to spend some time sharpening your skill then you can start with these free Algorithm courses. Preparing for Java Developer Interviews? Email Address Download Free Questions spect your privacy. Unsubscribe at any by ja pala Ebay 09,2022. Labels: cove aun, cone java ineriew question data siiclute and alot, ataetamming ‘41 comments Hetsenberg said Great pst Jain Realy help Ia cently asked flowing estions in interviews | have found answers via Googie search, but would be great to row your comments on these questo. 1. Wate your own Hashwap/Hashtable implementation inva 2. How to enplement your own LinkeList (thou sing any Java AP) ach 162002 at 1:58 avin Must Override Eine Era sid... ‘Heisenberg, Thanks fr sharing these question, they are rel good You can implement Hash by wing Array, because ely provid constant time acces, f you know index. Key isto writing hah function to minimize clin. Stat, you can implement lnked lst by creating Some clas e.. Node, which hols data and keep crack of next rode, By the way | wil try t blog answers in more deta. aren 46,2019 38 230004 SARAL SAXENA sid... 1 Javn, Get artcile once again regarding second question (How to ing inked list has loop, want to add the folowing thing. 1) Te eetermin if ke i as l9p 8 not Yeu can detect by simply runing two pont second poetrB 0 the second node +s trough the ist. Start the fist printer Aon the fst node and the Advance the fst peinter by one every time through the oop, advance the secon pointer by tw there i oo, they wil eventual pit othe same nade heres ne oop, youl eventually hit the en wth the advace-bytwo Conder the falling oo: Starting Aat 1 and a2 they take onthe folowing valves: 2 4s 54 Because theyre equal, and B shuld always be beyens A (because fs advancing by two a opposed ta the advanced ce beaviou of}, means youve cecoveres 3 lop. et nasLogp (ponte nodes) “+ Empty lest has 9 loos rode = nocoh.noxt we node = NULL | évance node by one, nose by to (wth ends chech) node next =~ WILL ret fe 1 1Fsame, we have a op. ncnhie texted witout loop maens ole. return false 2) Te second query if the pet at which oop stared. (nce yeu knew anode within the eo, finding the Fist odes a5. eres up wrapping around tA 3ann, then Ce before your lop. In tna ate, advance ¢ ang 8 by one and heep going. Eventual, ¢ wl enter the lop and be mat by B, at which plat (€ gos his way. Cos A(t ie where Aand B 1 rst met 1 (@ rune trough thi op, every tine ie roaches A you advance C: wen i reaches C, thats your fist loop node) SARAL Saxena Javea Regarding QS (How tind element trom een inked Un oe pss) ‘ne approncn cul be i terms of peeoco oc could a0 be The fst node la yu st am assuming scaled head Se sets pointer tend, weil cll it current Node cur neat Node treesnead ~neadnext.nex.ne Chroennead = threeshead nest; ‘en treeahetd.next becomes ul, you are thee poston from the end with erent so fall if youknow what the lenge ofthe Uist s before you sa, rade = fat for = 0 length- NFROM.END; 0) 1 In java Savi. Lnkasit: inked get inked siz) 3) but you dont naw the tenth res = naw Nodet¥ FROM. END]; rode = frst for (=O; de nl) odes = N_FRON, ED] = rode: } rent «nade N_FRON_END value cr something the that. (Chac the boundary corto. ané account forthe Uist eng FROM END.) being less than avin @ method overide error in ens java 5 sald ‘Sra Sauer, Great comment and hanks for your pssudo code, S66 hips. Il ry to caver question of detecting linked tse with on, may be anther post. Once again, thanks fr adding value ach 18200 at SsbA edvin and Sara, can w uy paste have a 00k below method ie crrct for Queation? lop sion tke) fabblie static veld teh ietinLeop{LinkedLiet. Node hend, Nede taf) { Linkeeist. Node node - head nxt; Linkeest. Node node ~ head next.ext) eno. ent rl ( ‘(nodes equate) breaks rode « nogeBinext); d System. out prntin Loop detected.) ) waren 2.2003 at 80396 Anonymous sad. Fer Question 3 anter sition could be (with java. UiLnkedist, pic state vod getrdlrenttromEnd ({ Svat. Lnkostst = new fra tL Linke) lacey, tae, acer): acer; acer: Waar aero Ine teotheadeo,tveeBack-o; System ost prntin size =" ae: inset > 396 fonsing 10 ¢ Cesarean} itebreoshess > 3) Uroebackes; ine = treednead - nreedack: System.outprintin f= ern System. outprntin Third Element Fram End = “all get threebiack: ) i ) Poste commen ths ston isnot perfect at any psnt ‘Avonyeus sai guys, recently an terviw I was asd how would you reverse Unked lst answered tha would have anew i, erate the erga inked st anal elements of i tat Hea of new it nterviewer wasnt convinced with iy answer. Anyway thought of writing a program to prove ths...hee is cmplete program. package example detastrctures pubic le Linkeltéxample ue state vod main(String a8) ( Node nea = new Node) for(int 3106) ‘ Inseeatathead, new Nede("I, ul) ) for(i 2360 ‘ fneertAtitondthend, new Nede(“ef, sulk: 1 teaverstisteae) reversListheas) lraverstistieadh seeteNode(hese, “10; twaverstistnead) i e * Ad erent at al of stati voi insert Node head, Node node) ‘ en) t head.net-node System. out prin Linked ats empty insert); 1 Node atode = headrests waile(astNode.nextnut) {lasNedeslastNade next; d IastNede.next=ode; ) * * deiete a nose matching dts static old deeteNode(Node head, String eat) c if tead.next == nl) t System, out prin inked ats empty in dlatehade d Node atNade = head next Node prevousNde = neae; wolelastNode!ul) c Idaswode.cataequaseat)) c breaks ) previeuode = astNede; InsNodeslatNede.next d e * ements head af it “1 static old nserttHead ede head, Node nade} c Hf (ead.next > nal System, ost prntin Linked sts empty inerththeae: d rode. next-hesd.net static vldraversListNede head) i Node astNode = head.next; t System. out prnln Linked at empty in traverse } System. out prnt/Data:*; wleasNode!-nal) c System. out print" + asNede data lastNodestastNede next; d System. out pret * Reverse nko Uist. static old reverseist(Nade ead) ( oe) t System. out prion Liked Ut serpy in verse, 1 e * Create a ike Uist by adng elements of orginal ist a hea of new it. Node newtead = new Node) Node latNade = hen next, Node tempNode; ‘wnleastNode!-rat) ‘ terpNode atNode: IartNode-IastNode next tempNede.next-newiead next: head.nex = newHead next; ) ) classNoce t String data; Node next: owed) o Node(strng eat, Node nex) c this dataneata; ths.next= next } i output Linke st is empty sertatast Data: 1234567 8910 Data: 10987654325 ata: 987654324 Pease sugest if anything wrong in is code ‘Taoks, Prashant maven 28,2019 a 10-300 ‘Anonymous si. Sere more coe.) Find mile clement 2 in nth element 3) Find and emve loop in st package example datastrctures pubic lass Linkelstéxanple ( pie state vod main trina) ( Node need = new Node far (| 3:10) £ Insereatathead, new Node“, ul) 1 for (tf -2360 1 Insertatend (head, new Node“, ul); i FndidaleEtement head); fineelemertrmlast ead 11 Greate eetect ne remove lop from st head = new Node) createisttaviegLoopiead) fedAndRemovelaophedrhosd): tenversetistinesa } ‘state vldremoveLoophodetNodeleophode, Node Neae) t Node nedet = hess Node nade = rl wile (ove) t ded = loopode wile (o6e2.not I= loop BE node2.rext = node!) ‘ ded = nade. net ) If oae2.net == net) ‘ break, ) t radete det next ) ) 1 stat vid fndAndRemoveLoopNode(Node head) t I peadinet = ul) { System. outprintin Linked tists empty fndLoopide' ) Node eurentNode = head.next: Node startNode=head; Node lastNadenead. nest. ret weelastNode!=ul) t ‘currentNode = crretNogenext; Ht ase. next rl) t lastde = astode.rext.next: ) IastNode = crrentNode) t Started» startNede.next; System. out pnt Loop Noce s+ crete data; removeLoophede(curentNode, head); 1 System. out prntin Loop node doesnt exit’) : stati vid creatlistHavngLoopiNade head) t Node nadet= ew Node, nls Node neded- new Node( rl Node nade new Node nl) Node sadet= new Node, rll) Node nadeS- ew Node rl) Node aadee= new Node, nul) Node sade7= new Node(7 rll) Node nedet= new Node, rls Node nade new Node( nu) Node nedetdr new Nede( 10, nosed Insetataithesd, node) Insertatraihea, nosed} inserAtahead, noes) Ineetataihend, node Insoreatathend, nos} InsetAtahen, oe) Insertatrathend, node?) insetataihesd, noes) insercAtraihea, nosed); sneereatathend, node; } sta vol intElemenstromiastNede hea, int eromLast) i Hf (esd.net = al) {Syster.out.pritloLinke st empty findthetementtromist ) Node curentNode = head.nxt; Node tempnode-head; far Git; KnthFroast t temmNode = temphade. next 1 lastNedertompsoee wae(astNode.nectnul) ( if gash. nex ft) {lanNode = asoce.nesti) currentNede~ curentNode. net } System. out prntinintFromas +" element from as ie: + curenthage ta); ) static void inddeeflementiNade bend) t 1 pesd.nent = nal) { Sytem.out pinto LUnked Ut empty fndiiceFlement at 0 Node mideatiode = head; Htength 42 ==0) t Inielehade~ migleiod ne i laetNode = ast. next } if gorges 22 t } syste. outprotinc Md lament is“ ideNode. bask ) pel, 2019 at 7.26404 oonymous 8. ‘ocL.28.2012 26 51.4 “rich eata-stvucture should ete detect deadlock betwsen thread? This was ake a write a routine to detect leadock froma pool of trends 0 me in a Java interview ap. 2013 at 2253 Gen a sings, anda st of strings of postive length, F812, 82,.FNRN, proceed to fn inorder the sccurcences(eftturigh) of Fin Sad replace ter with Al atrngs ae over alphabet (0, 1, Searching shoul consier only contguois pecs ofS tat have not been subject to replacements on prior iterations. An iteration ofthe tigorkthim shou not write over an previous replacement by the ager, ‘Wear program shauld accept es its First argument. & path to a fename. Each Une t this Mle ts ene text case. Each test 001 101100%;0110,1001,100,0,10,12 utput saat: For each ne of np, prin et the sing after subs sr100s10 For the euous, here are the transitions fr the above example: 10017011001 => 101001110" (replacing 0170 with 001} = 1010170 [replacing 100 with 0} => 11100110 replacing 10 with tH] => 11700110 June 19,2013 10: Anonymous sai 1 gy, want to check the two strings are matclng 70% or no. Can anyone els me ot an you help me: Consider the fle named crs. each tne nthe le contains infomation about a car (eat, Company, Manufacture, MoceKame, Typ 2) Ad each car which represented using oe tne ofthe fe Us. Use an object of the following cas Cass nose t Ine yar strgcempry: sxringladedame: stringy d A sing tnk 3) After creating your ist 9 the flowin 2. Print how many cars owned bythe person (8? 1 Prt how many cars ae on the Te eu need dee? «Prt everything about al the cars hat have been manufactured an 2012 ona newfie called 20:2are, Print al compas’ amas ona new called company, Note €. Print al the cars that has been Manufactured by Toyota na new fle called Toyota. Note, we need to gent oly the WadleNane. {Delete the fist car fn the Ut that manufatred by Hons an print the fie agai, Name the file Hon, f: Delete the last cr the Ut. Pit the result na new file called Print the ren na new fle calles Trucks caer 19,2015 a2 aloo sad ans of isnot corect. ts would be nl) 0=0.23.45,62.89,105 ine] n= new nfo iegeh th forint 0,1 «elena fetes: } forint 0; «olen a System. out prin eof» of] = 18°» ets } Fr Question oumber nine Hf we ust have to find the Duplicate values and nt ther occurance below code scent: import avai ase Import java.ubl set; t public Set getDuplicateValues(TD) arr) t Set shee = new Hasta enh forint 0; arent; 0) itehashset addon supictesaceari } i return duplctes 1 * oparam arse pai state vod main(String] men [ DyplieaterinderdupintetrngFinder = new Dupiateingert); Set duplicatestings = cuplatestingFnder getDupicatealuesnew Stn IC", °C, “8x; System. out prnin Duplicate strings are” + aupiatstrings ater): Dupleateriderduptstlnfinder new Duplicating; Set duplicateltegers = dpicalelntFinger getDupicatealuesrew Integer 2341.45.55): System, out print Duplicate integers ar: + duplicatelnegers.oSrng) } } December 4.2000 at 1AM tech show sa. Regering @2 ‘we can 6 by string the rest pointer values of each nde , any dupiate comes en to, we can alse da with two pointers On) simpy say ane slow pointer and oe as potter. slow pointer wil erase fre tie where a fast pant wil increase ice, 3 I weg fapaintersslawpinter then there i. and if faetpointer=al hen ro lop that Jeouay 16,2014 a6 2128 Write a routine x Java that kes an ater nai returns sum of 162. on and square of number 0 Ie =5,sum 19 and sare 25 «can anyone please gve me te solution can any one help me Wirt code in Java that prints: You are gen this routine private sate voidprintstarstint 0) for (ott =O; ny oa) Syste. outprinte™) } System. out printing) ) YOU NED to write the routine btw, which prints the above Figure. YOU CANNOT USE ANY LOOP STATEMENTS lke while, d, for ete ay 20.2084 13548) void prinstararrayintN) ‘ it == 0) returns printstarmrray{N: 1); 1 bv. 2014 a7 ‘Anonymous si. “Tanke alot forall blogs It helped me gota jb at major investment bank “anand as ashe this question at Deutche bank You can only buy stock fst and then sell tater that hor sling nat alowed) ve a soltion that is 0(6°2) pubic atc vote bestBuancSelndexe( Double price) ( prices = ul pies tength <2) ‘row naw Hegatagumentxceptin( No of prices ess than 2°) double prot = 0 Ine buyngex =, slindexe4; for(int #0; 1 proid £ profit = pies - priest buyndex } ) } rete» 0 ¢ System. out prntntrngfrmatTe best profit Xf can be abtaines by buying at (8th index ad sling a 0h nde, profit, priesfoulnéen], bund, pricssellnde], send) ) re System. out printing No scenario found to get nan-zero profi. ) } ly 26, 2014 9 92240, okoown sa tans (nce agaiparser ls ny code) ere O(n) salut: ps pastebin. com ETO Seplombor 18, 201431 39404 anybody help define srucuer employee with name, slary.employmanteay then define array of «employees ten a employee wth hight star and name fal employees who werk mare tha 10 years ame ofthe Seotember 22,2014 8221578 The Past sai Yur slution for fining the Ir nade frm te end ofthe st while may work ina a soltion that wil get passin an Inter sg two poiters shows a fandamenta lack of understating of haw to property travers it, ‘Theres we ways would accept a8 orreet, One sing a loop ar pointer: Or the even Deter way of ing ecsion. Both of thar would employ using next. next-mul; Recursive Fe 6 Ue this plc LstNodetndThiedLssNede n) {ths next.nextnnulthsfindTiras. next) (ne tine Sluis make you co ke the man Interviews. :) December 10,2014 4200 Anonymous sad. ‘Some more algertitn interview questions fer true coders: cadet implement rach sort write ede fortwo pivot uc agri b sda 1 acon 2.2015 at 26008 Anonymous sad. sorry fori nt se break olaown sad ii u ding the answer fr this question Could ups share it Movember 12.2015 a0 AM Anonymous sad. For Java Developers, | would say to prepare well for DS and Ago, you can check some sample Data sucture unstions here, once you ae good at tat, jut prepare same basc Java queton for telephonic round. Once you are dae that you ae ready, but f you want more confidence, you shoud check hs Mega USt of av8 cussions, Which conta care Java questions rclucng mult-¢hresding, exception handling, cllectins, GC, design pater and OOP questions fram Tas years of Java interviews. Anonymous sad Sf Lopen the appiations on my desktop one after another immed Iytven on which data structure the i. 2006 a 2128 Unknown si. an you please prove the cade fr you onn hashtable implementation with you own hashcode function Sentember 29,2016 at 4th Aronyeus sai “This cheat shet ia good resource, backed up by a github ree ps naman. com! dp/ 0692907815, tune 26201738 10:21 oul you a ink to question 14- youve alraey write the post with the arswer haps )avaceiste, blogspot.com 2017/63 /Raw-t-reerse-inkelitin-java-sngteraton-ané- recursion Rem avin paul sad etober 27,2008 at 1:24 andy said. ven please implement specified functions of ray Us {XefineElementType nt ‘eatin MANSIE 10 lypedet struct LNode st struct Node emant¥ype Data MASI} a Yeu need to implant the flowing Ky func Lis CreatedrrayLi 17 Te create an empty ary st ine Fnd(lementiypeX, List Prt; 17 Fincing ot an index ofan element old Ieert(ementIype Xa | Lt Put; 17 Ieertng anew eernant Void Delete(nt | Lt Ptr); // Delete pecfeg element void UpeateElementIype X, ns Ls Put; 17 Update a species clement nis ray List te down your cade here, the necessary code Post a Comment Q sx comment EF Subseribe to: Bost Comments Atom )

You might also like