Questions2014-2015
Short Description
IIT placement questions...
Description
Please add all questioorn in this doc with heading Company name @ College Name , Date Please group papers of same company together CONGRATULATIONS TO EVERY.We have decided at PGAB that fro Works ApplicationQuantitative test, Maths based, pretty easy
DIRECTI @IITKGP 18 NOV You are given a rectangular grid with 2 rows and N columns. The top row is labeled 1 and the bottom row is labeled 2. The columns are labeled from 1 to N in increasing order. Each cell in the grid contains a single character. 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 share a common edge with. There may be several such paths. Let us concatenate the characters in the order in which the cells are visited during a walk. The string formed can be called the string for the walk.
Among all the possible walks, and their respective strings, find out the lexicographically smallest string. We know that the length of the strings are all the same to be precise, 2N. Thus, the lexicographically smallest string is simply the alphabetically smallest string if you compare the characters from left to right.
Input The first line of input contains a number T, the number of test cases. Then follow T test cases. Each test case contains 3 lines. The first line contains the number N, the number of columns in the grid. It is well known of course that the grid contains rows. The next two lines contain the description of the grid in the form of two strings; the string of N characters in row 1 from left to right and the string of N characters in row 2 from left to right, respectively. Each character will be a lowercase english letter.
Outputlabs
Output a single line for each test case. The line must contain a string with 2N characters. This string should be the lexicographically smallest string for some hamiltonian walk in the grid.
Constraints 1 ≤ T ≤ 1001 ≤ N ≤ 10
Sample Input 2 gm3 abc def 10 ababaaabab bababababa
Sample Output 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 "Flip all the bits between start_index and end_index, inclusive". Given a sequ ence of several such operations, perform all the operations on the array. Finally, split the array into sets of 4 bits first four, next four, then next four and so on. Each set can represent a
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 / Output and explanation of Sample Input / Output for clarity.
Input The first line of input contains an integer T (1 ≤ T ≤ 10), the number of test cases. Then follows the description of T test cases. You should assume that the array has exactly 10,000,000 bits and that the bits are all unset at the start of each test case. 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 from start_index to end_index, inclusive. Also, the array is 1indexed meaning, the smallest index is 1 and the largest index is 10,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 created according to the problem statement, and so on.
Constraints 1 ≤ start_index ≤ end_index start_index ≤ end_index ≤ 10,000,000
Sample Input 2 2 1 4 9999997 10000000 2 3 6 5 8
Sample Output 2499998 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2499998 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0
Explanation In the first test case, after we perform the two operations and split the array into 2,500,000 groups of 4 bits, the first and the last group will have all 4 bits set representing 'f' hexadecimal digit. All the other groups will have all 4 bits unset representing '0' hexadecimal digit.
In the second test case, after we perform the two operations and split the array into 2,500,000 groups of 4 bits, the first two groups will have the state 0011. This represents the hexadecimal digit '3'. All the other groups will have all the 4 bits unset representing '0' hexadecimal digit
BrowserStack Round 2 @ IIT BHU (151114) Total 5 to 6 hours time. 3 Questions. Googling, use of any other site was allowed. Ques 1.) In this program you have to consume Twitter.com’s REST API.
Write a program that, given a hashtag H and a number N, ● fetches the N most recent images (no duplicates) associated with that hashtag ● and generates a webpage (an HTML file would do) which displays these images as a simple slideshow You may attempt this problem in any programming language but you may NOT use a thirdparty library like twitter4j . You may have to create a new Twitter account if you don’t already have one. Visit Twitter App Management to register a new app and obtain an API key. See Twitter REST API docs for more details.
Ques 2.) Consider the webserver log in the file sample.log
Write a shell script (zsh/bash) that parses this file and outputs the following: 1. the number of HTTP 404 errors in it 2. a list of all HTTP response codes in the log and their count You may download the log file and save it locally for testing purposes. For the second part, your script must find all responsScrape IMDB top 250 list and make a knowledge base which supports query for top movies of any given actoScrape IMDB top 250 list and make a knowledge base which supports query for top movies of any given actoScrape IMDB top 250 list and make a knowledge base which supports query for top movies of any given actoScrape IMDB top 250 list and make a knowledge base which supports query for top movies of any given actoScrape IMDB top 250 list and make a knowledge base which supports query for top movies of any given actoe codes in a generic fashion, you should not hardcode searches for a known list of response codes. The script must be a shell script Perl/Python/Ruby are not acceptable. Ques 3.) Scrape IMDB top 250 list and make a knowledge base which supports query for top movies of any given actor.
MICROSOFT @ IIT BHU + II T K (061114) 1 hour test conducted on cocubes.com 2 coding questions only. Questions same for all the students. Languages Only C , C++ , Java , C# were allowed. Ques 1. ) Convert a binary tree into it’s Mirror tree. Condition : Inplace conversion required. Ques 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. Eg . Input 37 tr Output 1 Input 165 Output 4
MICROSOFT @ IIT D + IIT KGP+ IIT M (061114) 1 hour test on cocubes.com 2 coding questions only. Questions same for all the students. Languages Only C , C++ , Java , C# were allowed. 1. Given an array of integers, find an index such that sum of the element of left side = sum of element of right siden array of integers, find an index such that sum of the element of left side = sum of element of right side input : 12 13 18 1 6 o/p: 2 because 12+13 = 18+1+6 2. Given an array of integers, find the maximum continuous sum such that no elements contributing to the sum, are repeated. I/p: 1 2 3 3 4 5 2 o/p: 14 as 3+4+5+2=14
MICROSOFT @ IIT G (061114) 1). http://www.geeksforgeeks.org/kthsmallestelementinarowwiseandcolumnwisesorted2d arrayset1/ 2). Given a binary tree and a number. If the tree has a roottoleaf 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.
DirectI Questions Links (Same questions asked in all IIT’s till now) http://www.codechef.com/DI14R018 t lIT BHU http://www.codechef.com/DI14R019 IIT BHU
http://www.codechef.com/DI14R024 IIT M (Set Bits and Smallest Rectangular
String problem) @IITM guys please post screenshots.The link is unaccessible. @IITDelhi Colorful Knapsack + Best 2x2 Sudoku @IITG @IITB
Adobe @ IIT BHU (41114) 2 Sections, 10 questions each section, total time 2 hours, Full subjective. Paper and pen test. All questions related to CSE. No aptitude questions. No MCQ’s. Some questions : ●
some microprocessor code given, tell answer
●
LCA of 2 nodes in BST
●
return pointer to middle of linked list in 1 pass
●
Array of size n1 has numbers 1 to n, one number missing, no number repeated, find the missing number
●
What is the best STL used to find matching parenthesis
●
some theoretical questions on pointers and function
●
find GCD using recursion
●
find max. of 3 numbers using ? : only
●
reverse a doubly linked list
●
find 2's compliment of a no. given in string form
●
some macro related questions
●
Given a Hash function, find value of keys having same hash
●
Given order of insertion of nodes, make BST
●
given 3AC, a number in base 14, convert it to base 7. (only show working on given example, no code or
algo) [ ans = 2105 ] ●
Simplify a given boolean expression.
●
Explain a) & b) a) void (*p)(void *a[], int n) b)void* (*p[])(void *a, int n)
@IITM
13 GATE pattern MCQs and 7 Coding Questions Platform : HackerRank TIme : 2 hrs Coding Questions: 1.
Reverse linked list
2.
Check balanced parentheses
3.
Given m*n binary matrix, where each row has all 1s first and then all 0s. You need to return row number which has maximum 1s.
4.
Every integer ending with 3 has at least one multiple which is made of only 1s. Ex. 3 has 111, 13 has 111111. Given integer n(LSD is 3), return its smallest such multiple.
MCQs: 1.
char str1[] = “Hello”; char str2[] = “Hello”; if(str1==str2) cout empty, 'R' > Red, 'G' > Green, 'B' > Blue A Blue strip has width 1 and length greater or equal to one. [Vertical]
A Red strip has length 1 and width greater or equal to one. [Horizontal] If a Red strip and a Blue strip overlaps, the overlapped portion will become 'G'.w Find the minimum n 1 horizontal strip from (0 0) to (0,3) 1 horizontal strip from (1,0) to (1,3) 1 horizontal strip from (2,0) to (2,0)
1 horizontal strip from (2,3) to (2,3) 1 vertical strip from (0,0) to (2,0) 1 vertical strip from (0,1) to (0,1) 1 vertical strip from (0,2) to (0,2) 1 vertical strip from (0,3) to (2,3) s so total 8 SAMSUNG Samsung India (R&D) at IIT Madras,20/10/2014 2 Rounds: Round 1: 60 mins Tip: Attempt the Math part first and Verbal the last. Short list based on score in Round 1 Round 2: coding round 1 hr Questions 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.
3 questions for A: x 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] Example: s1 = "qwewerrty" ; s2 = "wer " Output: qty (On the first removal of wer it becomes qwerty. On removal again now qty. Nothing to remove now.) 2.
a string, print the number of occurrences of 1[0]*1 where * denotes zero or more occurrences of the digit 0. [5 points]
Input: 10011abc10000001 Output: 3 3. Question had some robot and story build up but the essence is this: You are given an mxn grid , where (0,0) refers top most left position and (m1,n1) 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 atleast one path from (0,0) to (m1, n1). Find the minimum distance of the path from (0,0) to (m1, n1) given that you are allowed to move only vertically, horizontally and diagonally. [8 points] Another set of questions for Round 2. Adding the comment here for better visibility. 1. (5 points) Same as A's second question. 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) 3. (8 points) Given a word with unique lowercase characters, return its rank in a dictionary that consists only of words that are anagrams of the given word.
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. 1. Determine whether the anagram of a given string can be a palindrome. 2. Same as A's first. 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. )
Directi Directi @IITR, 18th October 2014 2 Questions 90 min. Platform codechef Q1: The ith stone has the color C[i] ( between 1 to M, inclusive). The Knapsack can hold a total weight of X. Fill knapsack with these stones. we have to select exactly one of each M stone colors. sum of the weights of the stones must not exceed X. We have to fill the Knapsack as much as possible.(hence minimize unused capacity.) Input number of test cases. The first line of each test case contains three integers, N, M and X, The N integers, W[1], W[2], W[3] ... W[N], (Weight ) N integers C[1], C[2], C[3] ... C[N], Output the unused capacity of the Knapsack (a single integer on a line by itself) for an optimal way. If there is no way to fill the Knapsack, output 1. Constraints
1 ≤ T ≤ 10 1 ≤ M ≤ 100 M ≤ N ≤ 100 1 ≤ W[i] ≤ 100 1 ≤ C[i] ≤ M 1 ≤ X ≤ 10000 Sample Input 3(test cases) 9 3 10(1 st test) 2 3 4 2 3 4 2 3 4(wt) 1 1 1 2 2 2 3 3 3(color) 9 3 10(2nd test ) 1 3 5 1 3 5 1 3 5(wt) 1 1 1 2 2 2 3 3 3(color) 3 3 10(3rd test) 3 4 4(wt) 1 2 3(color) Sample Output 0 1 1 Note: bruteforce solution will fail. Q2: There is a bit array of length 10000000. sAn operation is performed several times on this array with given start and end indices(one pair). An operation flips all bits b/w start and end indices(inclusive) of bit array. After the N operations, you need to tell the frequencies of 16 hex digits in that array. 00). Find maximum sum of the array which can be produced after the flip. eg For [0,1,0,0,1,0], output is 4…. flip from index 2 to 3. use kadane’s algo 2. Find two numbers from an array which sum to a given target. bruteforce won’t work 3. Situation is that some caterpillars start from the bottom and jumps to the next leaf. They eat the leaf before jumping to next. We are given an array which represents jump steps made by caterpillars. If the array is [2,4,7], it means caterpillar0 will eat leaf 2,4,6.. caterpillar2 will eat leaf 4,8,12.. and caterpillar7 will eat 7,14,21… 0 represents ground.Calculate the number of uneaten leaves. ( n
View more...
Comments