├── 2015-16 ├── Microsoft │ ├── Images-and-Raw-material │ │ ├── README.md │ │ ├── image29.jpg │ │ └── image34.jpg │ ├── Microsoft_IITK.md │ └── Microsoft_IITB.md └── Samsung-R-D │ ├── Samsung R&D_IITB.md │ └── Samsung R&D_IITBHU.md ├── 2016-17 ├── Adobe │ ├── Adobe_IITM.docx │ └── Adobe_IITR.md ├── Securifi │ └── IITM │ │ ├── Ans.docx │ │ └── securifi_IITM.zip ├── Hauwei │ ├── Hauwei_IITM.docx │ └── Hauwei_IITR.md ├── Tesco │ ├── IITM │ │ ├── Tesco_IITM.png │ │ └── Tesco_IITM.docx │ └── Tesco_IITR.md ├── IndiaMart │ └── IndiaMart_IITM.docx ├── Directi │ └── Directi_IITM │ │ ├── Directi.docx │ │ ├── Untitled document.docx │ │ └── Untitled document(1).docx ├── Samsung-R-D │ ├── Samsung R&D_ISMD (Internship).md │ ├── Samsung R&D_IITM.md │ ├── Samsung R&D_IITH.md │ └── Samsung R&D_IITD.md ├── Microsoft │ ├── Microsoft_IISc.md │ ├── Microsoft_IITD.md │ └── Microsoft_IITK.md ├── Fuzzy-Logix │ └── Fuzzy Logix_IITR.md ├── PayPal │ └── PayPal_IITR.md ├── Oracle │ └── Oracle_IITR.md └── Qualcomm │ └── Qualcomm_IITR.md ├── 2014-15 ├── Microsoft │ ├── Microsoft_IITG.md │ ├── Microsoft_IITBHU_IITK.md │ └── Microsoft_IITD_IITKGP_IITM.md └── Samsung │ └── Samsung_IITM.md └── README.md /2015-16/Microsoft/Images-and-Raw-material/README.md: -------------------------------------------------------------------------------- 1 | Add images and raw material in this folder to be used in other documents. 2 | -------------------------------------------------------------------------------- /2016-17/Adobe/Adobe_IITM.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saurabhsuniljain/Inter-IIT-IIIT-NIT-BITS-Placements/HEAD/2016-17/Adobe/Adobe_IITM.docx -------------------------------------------------------------------------------- /2016-17/Securifi/IITM/Ans.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saurabhsuniljain/Inter-IIT-IIIT-NIT-BITS-Placements/HEAD/2016-17/Securifi/IITM/Ans.docx -------------------------------------------------------------------------------- /2016-17/Hauwei/Hauwei_IITM.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saurabhsuniljain/Inter-IIT-IIIT-NIT-BITS-Placements/HEAD/2016-17/Hauwei/Hauwei_IITM.docx -------------------------------------------------------------------------------- /2016-17/Tesco/IITM/Tesco_IITM.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saurabhsuniljain/Inter-IIT-IIIT-NIT-BITS-Placements/HEAD/2016-17/Tesco/IITM/Tesco_IITM.png -------------------------------------------------------------------------------- /2016-17/Tesco/IITM/Tesco_IITM.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saurabhsuniljain/Inter-IIT-IIIT-NIT-BITS-Placements/HEAD/2016-17/Tesco/IITM/Tesco_IITM.docx -------------------------------------------------------------------------------- /2016-17/IndiaMart/IndiaMart_IITM.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saurabhsuniljain/Inter-IIT-IIIT-NIT-BITS-Placements/HEAD/2016-17/IndiaMart/IndiaMart_IITM.docx -------------------------------------------------------------------------------- /2016-17/Securifi/IITM/securifi_IITM.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saurabhsuniljain/Inter-IIT-IIIT-NIT-BITS-Placements/HEAD/2016-17/Securifi/IITM/securifi_IITM.zip -------------------------------------------------------------------------------- /2016-17/Directi/Directi_IITM/Directi.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saurabhsuniljain/Inter-IIT-IIIT-NIT-BITS-Placements/HEAD/2016-17/Directi/Directi_IITM/Directi.docx -------------------------------------------------------------------------------- /2015-16/Microsoft/Images-and-Raw-material/image29.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saurabhsuniljain/Inter-IIT-IIIT-NIT-BITS-Placements/HEAD/2015-16/Microsoft/Images-and-Raw-material/image29.jpg -------------------------------------------------------------------------------- /2015-16/Microsoft/Images-and-Raw-material/image34.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saurabhsuniljain/Inter-IIT-IIIT-NIT-BITS-Placements/HEAD/2015-16/Microsoft/Images-and-Raw-material/image34.jpg -------------------------------------------------------------------------------- /2016-17/Directi/Directi_IITM/Untitled document.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saurabhsuniljain/Inter-IIT-IIIT-NIT-BITS-Placements/HEAD/2016-17/Directi/Directi_IITM/Untitled document.docx -------------------------------------------------------------------------------- /2016-17/Directi/Directi_IITM/Untitled document(1).docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saurabhsuniljain/Inter-IIT-IIIT-NIT-BITS-Placements/HEAD/2016-17/Directi/Directi_IITM/Untitled document(1).docx -------------------------------------------------------------------------------- /2016-17/Samsung-R-D/Samsung R&D_ISMD (Internship).md: -------------------------------------------------------------------------------- 1 | Three questions as follows : 2 | 3 | 1. Kth largest element in a BST. 4 | 2. Sum of primes in a range. 5 | 3. Unique triplets that form a given product. 6 | -------------------------------------------------------------------------------- /2016-17/Samsung-R-D/Samsung R&D_IITM.md: -------------------------------------------------------------------------------- 1 | **Problem Statement** : f(n) = a * n + b * n * floor (logn) + c * n^3 2 | 3 | **Input** : a,b,c,k 4 | 5 | **Output** : Value of positive integer n for which f(n) equals k for given a,b,c. 0 if no such value of n satisfies. 6 | -------------------------------------------------------------------------------- /2016-17/Microsoft/Microsoft_IISc.md: -------------------------------------------------------------------------------- 1 | #Profile : Research Engineer 2 | ##Online Round (23 Oct, 2016) 3 | 4 | Three coding questions. 5 | 6 | 1. Find next smallest palindrome (range 10^100). 7 | 2. Find number of triangles can be found from numbers given in array. 8 | 3. Convert number into decimal form .(Recurrence decimal form). 9 | -------------------------------------------------------------------------------- /2016-17/Microsoft/Microsoft_IITD.md: -------------------------------------------------------------------------------- 1 | #Online Round (21 Oct, 2016) 2 | 3 | **Platform** : Hackerrank Full screen 4 | 5 | **Time** : 75 min 6 | 7 | 3 Questions. 8 | 9 | 1. http://www.geeksforgeeks.org/longest-zig-zag-subsequence/ 10 | 2. http://www.geeksforgeeks.org/find-excel-column-name-given-number/ 11 | 3. https://www.hackerrank.com/challenges/matrix-rotation-algo 12 | -------------------------------------------------------------------------------- /2015-16/Microsoft/Microsoft_IITK.md: -------------------------------------------------------------------------------- 1 | #Group Fly 2 | 3 | Two questions : 4 | 5 | 1. Given a general binary tree (not necessarily full or complete, just any binary tree), assume every node has three pointers - left, right, next. Use next pointer to link together all nodes that are in the same level. 6 | 2. Given a string, replace all consecutive occurrences of a character by a single instance. Eg: tommorrow ⇒ tomorow. 7 | -------------------------------------------------------------------------------- /2016-17/Hauwei/Hauwei_IITR.md: -------------------------------------------------------------------------------- 1 | #Online Round 2 | There were two sections as follows : 3 | 4 | 1. **Section 1** : 15 questions (30 min) 5 | Topics : 6 | 1. OS 7 | 2. CO 8 | 3. Data Structures 9 | 4. Algorithm 10 | 5. C++ : Codes are given and need to find its output. 11 | 12 | 2. **Section 2** : 2 Coding questions (60 min) 13 | 1. [Edit Distance] (http://www.geeksforgeeks.org/transform-one-string-to-another-using-minimum-number-of-given-operation/) 14 | 2. LCA in BST. 15 | -------------------------------------------------------------------------------- /2016-17/Microsoft/Microsoft_IITK.md: -------------------------------------------------------------------------------- 1 | #Online Round (24 Oct, 2016) 2 | 3 | 3 questions as follows : 4 | 5 | 1. Search Element : Search element in a sorted matrix (both rows and columns are sorted). 6 | 2. [Find Premutation] (https://www.interviewbit.com/problems/find-permutation) : Given a sequence of D and I (D for decreasing and I for increasing) generate the smallest number which satisfies the given sequence, ex ID -- ans 132, DD ans 321, DI ans 213. One constraint was all digits should be distinct. 7 | Answer to input “ID” should be 132 right. 8 | 3. (Not yet updated by IITK) 9 | -------------------------------------------------------------------------------- /2016-17/Samsung-R-D/Samsung R&D_IITH.md: -------------------------------------------------------------------------------- 1 | ##Finding cycles in a graph 2 | Time: 3hrs 3 | 4 | **Problem Statement** : Find a cycle in a directed graph and print it in ascending order of vertex involved. 5 | 6 | **Input** : `n` `m` (number of vertices, number of edges). Then in next m lines a pair of vertices representing an edge. 7 | 8 | **Output** : Print the cycle in ascending order of vertices involved. 9 | 10 | **Assumptions** : If more than one cycle you can print any one of them. 11 | 12 | **Library Functions Allowed** : Only input/output functions allowed and malloc if using C. 13 | -------------------------------------------------------------------------------- /2016-17/Fuzzy-Logix/Fuzzy Logix_IITR.md: -------------------------------------------------------------------------------- 1 | # Online Round 2 | There were 4 sections, 1.5 hours. 3 | ## 1. Quant - MCQ (15 questions, 19 mins) 4 | ## 2. SQL - MCQ (10 questions, 14 mins) 5 | ## 3. CS [Bitwise Operators mainly] - MCQ (10 questions, 17 mins) 6 | ## 4. Coding - (2 questions, 40 mins) - Some questions are as follows 7 | a. [Reverse all the words of a string] (http://www.geeksforgeeks.org/reverse-words-in-a-given-string/) 8 | b. [LCS] (http://www.geeksforgeeks.org/longest-common-substring) 9 | c. Coin Change - DP 10 | d. Fibbonaci 11 | e. Tree (Given Pre-order and In-order find post order) 12 | f. LCA 13 | -------------------------------------------------------------------------------- /2014-15/Microsoft/Microsoft_IITG.md: -------------------------------------------------------------------------------- 1 | #Online Round (06 Nov, 2014) 2 | 3 | **Time**: 1 hour 4 | 5 | **Platform** : cocubes.com 6 | 7 | **Format** : 2 coding questions only. Questions same for all the students. 8 | 9 | **Languages** : - Only C , C++ , Java , C# were allowed. 10 | 11 | 1. [Kth smallest element] (http://www.geeksforgeeks.org/kth-smallest-element-in-a-row-wise-and-column-wise-sorted-2d-array-set-1/) 12 | 13 | 2. Given a binary tree and a number. If the tree has a root-to-leaf path such that adding up all the values along the path equals the given number, return depth of that leaf (minimum, if multiple paths), Return -1 if no such path can be found. 14 | -------------------------------------------------------------------------------- /2015-16/Samsung-R-D/Samsung R&D_IITB.md: -------------------------------------------------------------------------------- 1 | #Online Round 2 | **Single coding question** : 3 | 4 | **Problem Statement** : Given n*n matrix (n<=100), where some cells will have mirrors of one of two types. Type 1 : “/” and Type 2 : “\”. These mirrors will reflect light by 90 degree. A single ray of light enters at (0,0). You have to find out the count of the number of reflections on mirrors before the ray leaves the grid. 5 | 6 | **Solution** : store current direction (4 directions possible). If current cell has mirror, update direction correspondingly and increase reflection count. Also keep updating x, y coordinates given direction. When current coordinates reach out of grid print the count. 7 | -------------------------------------------------------------------------------- /2016-17/PayPal/PayPal_IITR.md: -------------------------------------------------------------------------------- 1 | #Details of Test 2 | 3 | **Test Platform** : Hackerrank 4 | 5 | **Duration of test** : 90 min 6 | 7 | **Format** : 15 MCQs and 1 Coding. 8 | 9 | **Topics** : Aptitude, Logical Reasoning, Code Snippets(output of a segment of code), C/C++ based questions, PHP, pl/SQL, Huffman Coding. 10 | #Coding questions : 11 | ##1. [1st & 2nd slot] (https://www.careercup.com/question?id=5840928073842688) 12 | ##2. [3rd slot] (https://www.careercup.com/question?id=5721734273564672) 13 | 14 | #Suggestions: 15 | MCQ questions were easy try completing them as fast as you can( 20-25 min) and give more time to coding part. 16 | There is no limit of time to any section all 16 questions are given all together. 17 | -------------------------------------------------------------------------------- /2014-15/Microsoft/Microsoft_IITBHU_IITK.md: -------------------------------------------------------------------------------- 1 | #Online Round (06 Nov, 2014) 2 | 3 | **Time**: 1 hour 4 | 5 | **Platform** : cocubes.com 6 | 7 | **Format** : 2 coding questions only. Questions same for all the students. 8 | 9 | **Languages** : - Only C , C++ , Java , C# were allowed. 10 | 11 | 12 | 1. Convert a binary tree into it’s Mirror tree. Condition : In-place conversion required. 13 | 14 | 15 | 2. Given a number, return the number of set bits of the number if binary representation of the number is a palindrome, else return -1. Condition : You can’t use array or any other data structure. 16 | Eg . 17 | 18 | **Input** : 37 19 | 20 | **Output** : -1 21 | 22 | **Input** : 165 23 | 24 | **Output** : 4 25 | -------------------------------------------------------------------------------- /2016-17/Oracle/Oracle_IITR.md: -------------------------------------------------------------------------------- 1 | # Online Round 2 | There were three sections as follows : 3 | 4 | 1. **Coding Skills (15 questions, 25 mins)** 5 | Two sub-sections as follows : 6 | 1. Binary Tree - RBT (10 questions, 15 mins) 7 | 2. Binary Tree - AVL (5 questions, 10 mins) 8 | 9 | 2. **Computer Science Knowledge (17 questions, 15 mins)** 10 | Three sub-sections as follows : 11 | 1. OS and Data Structure (6 questions, 5 mins) 12 | 2. Big O notation and OOAD (6 questions, 5 mins) 13 | 3. Database (5 questions, 5 mins) 14 | 15 | 3. **Software Engineering Aptitude (45 questions, 40 mins)** 16 | Five sub-sections as follows: 17 | 1. Maths and Reasoning 18 | 2. Logical Thinking (7 questions, 6 mins) 19 | 3. Persistance Thinking 20 | 4. Data Interpretations 21 | 5. Programming Ability (Flow charts) 22 | -------------------------------------------------------------------------------- /2014-15/Microsoft/Microsoft_IITD_IITKGP_IITM.md: -------------------------------------------------------------------------------- 1 | #Online Round (06 Nov, 2014) 2 | 3 | **Time**: 1 hour 4 | 5 | **Platform** : cocubes.com 6 | 7 | **Format** : 2 coding questions only. Questions same for all the students. 8 | 9 | **Languages** : - Only C , C++ , Java , C# were allowed. 10 | 11 | 1. Given an array of integers, find an index such that sum of the element of left side = sum of element of right side array of integers, find an index such that sum of the element of left side = sum of element of right side. 12 | 13 | **Input** : 12 13 18 1 6 14 | 15 | **Output** : 2 because 12+13 = 18+1+6 16 | 17 | 2. Given an array of integers, find the maximum continuous sum such that no elements contributing to the sum, are repeated. 18 | 19 | **Input** : 1 2 3 3 4 5 2 20 | 21 | **Output** : 14 as 3+4+5+2=14 22 | -------------------------------------------------------------------------------- /2016-17/Qualcomm/Qualcomm_IITR.md: -------------------------------------------------------------------------------- 1 | **Format** : All were MCQs, no coding questions. There were 3 sections as follows. 2 | ##Section 1 : Aptitude : 20 Questions (30 min) 3 | Standard aptitude, Einstein Puzzle etc 4 | ##Section 2 : Programming : 20 Questions (30 min) 5 | Given a code snippet and a blank space choose from the options which completes the program. Sometimes output of the program. 6 | ##Section 3 : Theoretical 20 Questions (30 min). 7 | Choice to choose between 3 (CS, Electronics & Comm) 8 | ###CS Questions on 9 | 1. DS (Insert, Delete and Pre order traversal of Heap) 10 | 2. Computer Arch (Page faults) 11 | 3. Digital Logic Design (Number of OR gates required in 4-bit Full Adder 12 | 4. Linux (which API used to manipulate time : time_create(), time_get(), alarm(), pause() 13 | 5. OS (Optimal Page Replacement Algorithm, Process Scheduling) etc. 14 | -------------------------------------------------------------------------------- /2016-17/Samsung-R-D/Samsung R&D_IITD.md: -------------------------------------------------------------------------------- 1 | **Problem Statement** : 2 | 3 | Mr. Kim has to deliver refrigerators to N customers. From the office, he is going to visit all the customers and then return to his home. 4 | Each location of the office, his home, and the customers is given in the form of integer coordinates (x,y) (0≤x≤100, 0≤y≤100). 5 | The distance between two arbitrary locations (x1, y1) and (x2, y2) is computed by |x1-x2| + |y1-y2|, where |x| denotes the absolute value of x; for instance, |3|=|-3|=3. The locations of the office, his home, and the customers are all distinct. 6 | You should plan an optimal way to visit all the N customers and return to his among all the possibilities. You are given the locations of the office, Mr. Kim’s home, and the customers; the number of the customers is in the range of 5 to 10. 7 | Write a program that, starting at the office, finds a (the) shortest path visiting all the customers and returning to his home. Your program only have to report the distance of a (the) shortest path. 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Inter-IIT-IIIT-NIT-BITS-Placements 2 | This repository contains questions from Online Test and Interviews of various companies at placement in IITs, IIITs, NITs and BITS 3 | 4 | # Structure of the Repository 5 | This is organised by Year, then by Company and then by college. 6 | 7 | # Adding to the repository 8 | ## Creating new folder 9 | 1. Click on create new file 10 | 2. Type the name of the folder you want to create in file name. 11 | 3. Type `\` after the name, the folder will be created. 12 | 4. Add a file under this folder. [May be dummy] 13 | 14 | ## Naming a file 15 | Name the file using this format `companyName_collegeName`. 16 | 17 | ## Adding or Uploading files 18 | You can just add questions in a text file and upload it under the appropriate folder. You can add images as well. If folder is not already present you can create new one by following instructions under **Creating new folder**. 19 | 20 | ## Types of files to add and formatting. 21 | Try to avoid such files which can't be displayed in the browser such as .docx files. 22 | 23 | Add text files, images or .md files with [Markdown Formatting] (https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet). 24 | -------------------------------------------------------------------------------- /2016-17/Adobe/Adobe_IITR.md: -------------------------------------------------------------------------------- 1 | # Coding Round (3 questions) 2 | 1. Given a string containing only ‘+’ and ‘-’, find the length of the longest substring containing only ‘+’. 3 | 2. Given a word list and a sentence determine the least cost of generating the sentence from the words given in the list. A valid sentence is a combination of 1 or more words without any spaces and can contain any permutation of the words. Eg if list contain “abc” then the sentence can contain “abc”, “cab”, “bac”, etc. The cost is defined as the number of places where the word in the sentence and the corresponding word in the list differ from each other. Eg if list has abc and sentence contains a substring “cab” then the cost = 3. Assumptions : You can use the same word multiple times and any transformation each time you use it. Assumed Constraints : 1 < |s| < 5000 [Passed all test cases]. 4 | 3. Problem : There are n people numbered 1 to n. Some people are enemy, such pairs are given. You can form a group from range X to Y (from person numbered X to person numbered Y, all included) if and only if there is no pair (i,j) between X and Y such that (i,j) is enemy. Find how many total groups you can form. Constraints : 1 <= N, M <= 10^6. 5 | 6 | #Solutions 7 | 1. Trivial (Find all substrings and print maximum) 8 | 2. 9 | 3. Approach : DP (store for each person till how far he can from the group). 10 | 11 | dp[i] = min(dp[i+1], next_enemy(i)) 12 | 13 | next enemy is the first enemy of i after index i. [Can be found in O(n) time overall - assign all next[i] to n+1, now process each pair of enemy (i,j) if j>i update next[i] = min(next[i],j) else update next[j] = min(next[j],i) ] 14 | 15 | Final answer : After calculating dp array, do summation of (dp[i] - i) for i = 1 to N. 16 | -------------------------------------------------------------------------------- /2015-16/Samsung-R-D/Samsung R&D_IITBHU.md: -------------------------------------------------------------------------------- 1 | #Online Round 2 | 1. **Problem Statement** : Here you've to find number of H,L,T,U in a NxN grid (contains only 0 and 1). Each pattern can be represented in form of 3x3 matrix and can be rotated in 90,180,270 degrees. 3 | 4 | H - 5 | 6 | 1 0 1 1 1 1 7 | 8 | 1 1 1 0 1 0 9 | 10 | 1 0 1 1 1 1 11 | 12 | L - 13 | 14 | 1 0 0 15 | 16 | 1 0 0 and three more forms 17 | 18 | 1 1 1 19 | 20 | T - 21 | 22 | 1 1 1 23 | 24 | 0 1 0 and three more forms 25 | 26 | 0 1 0 27 | 28 | U - 29 | 30 | 1 0 1 31 | 32 | 1 0 1 and three more forms 33 | 34 | 0 1 0 35 | 36 | **Sample Test Case** 37 | 38 | **Input** : 39 | 40 | 0 0 1 1 1 0 1 0 0 41 | 42 | 0 0 0 0 1 0 1 1 1 43 | 44 | 0 0 0 0 1 0 1 0 0 45 | 46 | 0 0 0 0 0 0 0 0 0 47 | 48 | 1 1 1 0 0 0 1 1 0 49 | 50 | 0 1 0 0 0 0 0 0 1 51 | 52 | 1 1 1 0 0 0 1 1 0 53 | 54 | **Output** : 1 1 1 1 55 | 56 | It is guaranteed that a valid pattern exists and two patterns are separated by boundary of one. 57 | 58 | 2. **Problem Statement** : Given height of N*N buildings in form of NXN matrix and a ball can be assumed to be dropped from a building. Ball will fall on its neighbour having lowest height. 59 | e.g. ball from a[i][j] will fall on min(a[i+1][j],a[i-1][j],a[i][j+1],a[i][j-1]) and goes on falling. 60 | You have to find length of maximum path that can be traversed by ball. 61 | 62 | **Input** : 63 | 64 | 3x3 65 | 66 | 1 2 3 67 | 68 | 4 8 9 69 | 70 | 6 0 5 71 | 72 | **Output** : 4 (9->3->2->1) 73 | -------------------------------------------------------------------------------- /2016-17/Tesco/Tesco_IITR.md: -------------------------------------------------------------------------------- 1 | #Online Round 2 | **Format** : 2 coding questions, 90 mins 3 | ##Questions 4 | 1. Police and Theives : 5 | 6 | **Problem Statement** : 7 | 8 | Given a n*n matrix with either a ‘P’ police or ‘T’ thief in each cell, a police officer can only catch a thief in its row who is in the range k(given) of the police officer in either direction. 9 | Find out maximum no. of thieves that can be caught. 10 | Each police officer can catch up to 1 thief only. 11 | 12 | **Example**: 13 | 14 | 1 15 | 16 | n=3 k=1 17 | 18 | P T P 19 | 20 | T P T 21 | 22 | T T P 23 | 24 | Solution is 3. Every police officer can catch a thief. 25 | 26 | 2. Manjhi: The mountain man 27 | 28 | **Problem Statement** : 29 | 30 | Manjhi and the dragon with power ‘p’ is separated by an some rocks (array H[n]), with labels 1,2 or 3. 31 | Every rock (but not the 1st and the last, as then the dragon will be able to attack the village) must be broken to fight with the dragon. 32 | Breaking a rock decreases power of dragon by the factor( H[i] ^ H[i-1] ^ H[i+1]) and takes H[i] power of manjhi to break it. Manjhi wants to minimize the power of dragon after breaking all the stones except 1st and last. Can you help Manjhi?? 33 | 34 | ##Solutions 35 | 1. Approach : Can be done in O(n) by using two pointers. 36 | 1. Prepare two arrays to store indices of police and thief. 37 | 2. Now use two pointers to mark current police and current thief, initialized to 0. 38 | 3. 39 | 1. If thief is in range of police, increment both police and thief pointers and increase count by 1, 40 | 2. else if thief is on left outside the range increase thief pointer, 41 | 3. else increase police pointer. 42 | 4. Repeat till both police and thief pointers are less than X.end() [X can be police or thief vector containing, their indices]. 43 | 44 | Process each row independently. 45 | 46 | **Overall Complexity** : O(n^2) ( 1 <= N <= 1000) [for whole matrix, O(n) for each row.] 47 | 2. Hint: 48 | Use dynamic programming. Similar to matrix chain multiplication 49 | Think why greedy won’t work.?? 50 | -------------------------------------------------------------------------------- /2014-15/Samsung/Samsung_IITM.md: -------------------------------------------------------------------------------- 1 | #Online Round (20 Nov, 2014) 2 | 3 | 2 Rounds: 4 | ## Round 1: MCQs - 60 mins 5 | Tip: Attempt the Math part first and Verbal the last. 6 | Short list based on score in Round 1 7 | ## Round 2: Coding round - 1 hr 8 | Questions 9 | Online were different for different people. Questions collected from a limited pool of questions and jumbled sequence words) was ignored because we limit queries to 32 word for everyone. 10 | 11 | ------------------------------------------------------------------------------------------------------------------------------------------------- 12 | ###Set A : 13 | ------------------------------------------------------------------------------------------------------------------------------------------------- 14 | 15 | 1. Given a string s1 remove all occurrences of the string s2 in string s1 and also remove all occurrences of string s2 after removal of s2 in s1 and so on.. and return the string obtained after such removals. [5 points] 16 | 17 | Example: s1 = "qwewerrty" ; s2 = "wer " 18 | 19 | Output: qty (On the first removal of wer it becomes qwerty. On removal again now - qty. Nothing to remove now.) 20 | 21 | 2. Given a string, print the number of occurrences of 1(0)*1 where * denotes zero or more occurrences of the digit 0. [5 points] 22 | 23 | Input: 10011abc10000001 24 | 25 | Output: 3 26 | 27 | 3. Question had some robot and story build up but the essence is this: 28 | You are given an mxn grid, where (0,0) refers top most left position and (m-1,n-1) the bottom most right. The grid is filled with ones. All positions in the grid that are blocked are filled with zeros. You are given this grid and are assured that there exists at least one path from (0,0) to (m-1, n-1). Find the minimum distance of the path from (0,0) to (m-1, n-1) given that you are allowed to move only vertically, horizontally and diagonally. [8 points] 29 | 30 | ------------------------------------------------------------------------------------------------------------------------------------------------- 31 | ###Set B : Another set of questions for Round 2. Adding the comment here for better visibility. 32 | ------------------------------------------------------------------------------------------------------------------------------------------------- 33 | 34 | 1. (5 points) Same as A's second question. 35 | 2. (5 points) Given two linked lists, where each node of a list contains the exponents and coefficients of a polynomial (in decreasing order of exponents, zero coefficients don't have nodes associated with them), perform multiplication of the two polynomials and return a linked list with the result (conditions similar to the input - decreasing order of exponents, terms with zero coefficients should not be present in the linked list). 36 | 3. (8 points) Given a word with unique lower-case characters, return its rank in a dictionary that consists only of words that are anagrams of the given word. 37 | Eg: "take" : 6 words start with 'a', 6 with 'e', 6 with 'k', 1 with t, and finally "take", so its rank is 6 + 6 + 6 + 1 + 1 = 20. 38 | 39 | ------------------------------------------------------------------------------------------------------------------------------------------------- 40 | ###Set C : 41 | ------------------------------------------------------------------------------------------------------------------------------------------------- 42 | 43 | 1. Determine whether the anagram of a given string can be a palindrome. 44 | 2. Same as A's first. 45 | 3. You're given an array of integers. Return the largest number you can make using all the digits in the array. e.g: a=[23,45,67], return 765432. (concat everything, sort and return. ) 46 | 47 | ------------------------------------------------------------------------------------------------------------------------------------------------- 48 | -------------------------------------------------------------------------------- /2015-16/Microsoft/Microsoft_IITB.md: -------------------------------------------------------------------------------- 1 | #Online Round (30 Oct 2015) 2 | 3 | **Platform** : Cocubes 4 | 5 | **Format** : Two sections Aptitude and Coding. 6 | 7 | ## Aptitude - 15 MCQs (30 mins) 8 | 9 | 1. The number of leaf nodes in a rooted tree of n nodes, with each node having 0 or 3 children is: 10 | 11 | Ans : (2n+1)/3 (Geeksquiz question) 12 | 13 | 2. Fetch_And_Add(X,i) is an atomic Read-Modify-Write instruction that reads the value of memory location X, increments it by the value i, and returns the old value of X. It is used in the pseudocode shown below to implement a busy-wait lock. L is an unsigned integer shared variable initialized to 0. The value of 0 corresponds to lock being available, while any non-zero value corresponds to the lock being not available. 14 | 15 | `AcquireLock(L){ 16 | while (Fetch_And_Add(L,1)) 17 | L = 1; 18 | } 19 | ReleaseLock(L){ 20 | L = 0; 21 | }` 22 | 23 | Ans :fails as L can take on a non-zero value when the lock is actually available (GeeksQuiz) 24 | 25 | 3. Unary operator - in c. //what to infer from bridge, can someone explain 26 | 27 | options: a) 165 b)170 c) 195 d) 209 28 | 29 | Ans??-- did someone get the ans for this? (How??) wasn’t there a condition like steps should be minimum? Otherwise it can go to infinity (going into a loop) or at least a condition like we can go only once on any block. 30 | 31 | 4. Linked List What is the output (Not remembering exact Questions) 32 | 33 | 5. Linked List What is the output (Not remembering exact Questions) 34 | List was given 1-2-3-4-5-6-7-8; Some operation on list and list was printed at last. 35 | 36 | 6. Question on Virtual Function: (What is output) 3 classes were given each overriding same function of base class. 37 | Array of base class storing objects of 3 classes. Then a call to functions made. 38 | 39 | 7. Question on Java Char Array, character stream. (What is output) 40 | 41 | 8. What is output of this C++ code: ( not remembering exact code) Conversion Operator overloading: 42 | 43 | 9. Question on C preprocessing : (Not remembering exactly) 44 | 45 | But was somewhat like this: 46 | edi 47 | } 48 | 49 | Options:a) 11, b) compile error , c).. , d).. 50 | 51 | doubt: what will while(s(90),4) do. I think s(90)=”90” right?? 52 | 53 | 54 | 10. Questions on Structure pointers 55 | 56 | 11. Questions on Structure pointers 57 | 58 | 12. Consider a weighted complete graph G on the vertex set {v1, v2, ..vn} such that the weight of the edge (vi, vj) is 2|i-j|. The weight of a minimum spanning tree of G is: 59 | 60 | (A) n - 1 (B) 2n- 2 (C) nC2 (D) 2 (GATE CS 2006) 61 | 62 | ans: 2n-2 63 | 64 | 13. Consider the following array of elements. 〈89, 19, 50, 17, 12, 15, 2, 5, 7, 11, 6, 9, 100〉. The minimum number of interchanges needed to convert it into a max-heap is: 65 | 66 | a) 3 b) 4 c) 5 d) 2 67 | 68 | ans: 3 69 | 70 | 71 | 14. Not remembering 72 | 73 | 15. Not remembering 74 | 75 | ## Coding - 2 questions (1 hour) 76 | 77 | 1. Longest Even Length Substring: 78 | 79 | **Problem Statement** : Given a string of digits. Find the length of longest even length substring such that the sum of left part = sum of right part. Return 0 if no such substring exists. 80 | 81 | **Example**: Given string 1523457. The longest even length substring will be 5234. So output = 4. 82 | 83 | ![alt text] (https://github.com/saurabhsuniljain/Inter-IIT-IIIT-NIT-BITS-Placements/blob/master/2015-16/Microsoft/Images-and-Raw-material/image29.jpg) 84 | 85 | 2. Minimum difference of subarray [TUG OF WAR] 86 | 87 | **Problem Statement** : Given an array of length n. Divide the array between two subarrays such that diff between sum of each subarray should be minimum. For even n: subarray lengths should b n/2 exact, for odd n: subarray lengths should be (n-1)/2 and (n+1)/2 88 | 89 | **Example** : Given array 5,6,11,13,14,25. Two subarrays: {5,6,25} and {11,13,14}. 90 | ![alt text] (https://github.com/saurabhsuniljain/Inter-IIT-IIIT-NIT-BITS-Placements/blob/master/2015-16/Microsoft/Images-and-Raw-material/image34.jpg) 91 | --------------------------------------------------------------------------------