Forum Posts
- 1 Answer codechef puzzle problem
Johnny has some difficulty memorizing the small prime numbers. So, his computer science teacher has asked him to play with the following puzzle game frequently.
- Rahul Sharma September 18, 2013
The puzzle is a 3x3 board consisting of numbers from 1 to 9. The objective of the puzzle is to swap the tiles until the following final state is reached:
1 2 3
4 5 6
7 8 9
At each step, Johnny may swap two adjacent tiles if their sum is a prime number. Two tiles are considered adjacent if they have a common edge.
Help Johnny to find the shortest number of steps needed to reach the goal state.
Input
The first line contains t, the number of test cases (about 50). Then t test cases follow. Each test case consists of a 3x3 table describing a puzzle which Johnny would like to solve.
The input data for successive test cases is separated by a blank line.
Output
For each test case print a single line containing the shortest number of steps needed to solve the corresponding puzzle. If there is no way to reach the final state, print the number -1.
Example
Input:
2
7 3 2
4 1 5
6 8 9
9 8 5
2 4 1
3 7 6
Output:
6
-1| Flag | PURGE - 1 Answer Data Structures
Real life applications of Post and Prefix evaluation?
- 4m7u1 September 12, 2013| Flag | PURGE - 1 Answer If you have an offer that you ...
If you have an offer that you have accepted, and you tell Microsoft that, they will ask you for contact details of the HR of the company whose offer you signed to contact them and ask them if its ok for Microsoft to interview you, if you dont give them details they will cancel your interview.
- Illusion September 12, 2013
Microsoft has this policy where they dont consider you as a candidate if you have signed an offer already (and they know this, you can just as easily hide it) and will ask you to re apply after 8 months.
Please be careful of what details you reveal. My personal experience, I went on site and just to come back without being interviewed because I told them I have signed an offer and the only reason why I am attending the interview is because Microsoft is the better option.| Flag | PURGE - 1 Answer Interview "red flags"
Hi,
- Miguel Oliveira September 09, 2013
In the beginning of CtCI book, Gayle talks about the case of a student which she referred but had too many "red flags".
Could you elaborate more on the "red flags"? Maybe with a few more examples of these kind of mistakes that we should avoid in an interview?| Flag | PURGE - 0 Answers strings
implement the strtok() functin in C,, the strtok() function first takes the string for the first time, then it takes a NULL value, like this
- nathalie.imseeh September 08, 2013
/* walk through the first token*/
token = strtok(str, s);
/* walk through other tokens */
while( token != NULL )
{
printf( " %s\n", token );
token = strtok(NULL, s);
}
so you must write as a source code for the strtok() in C| Flag | PURGE - 2 Answers A fun little algorithms problem
Here's a fun but simple one
- Javeed September 07, 2013
Say you are moving from terminal to terminal in an airport, using the conveyor walkways (the ones no one ever really uses). You want to find the fastest way to get to your next flight, but each walkway has a certain amount of time from when you get on till you get off that will be consumed. Switching between walkways takes time k.
At any given point, there are two available walkways (one on your left, and one on your right). Assume all walkways are the same length, they just move at different rates, so when you get off of one, you have two possible choices, left or right. If you are on left, and choose right, add k to the amount of time you take, and vice versa. For n pairs of walkways, find the fastest way to get to your next terminal.
To give some variables for you to use:
n = pairs of walkways
k = time to switch sides, assume constant regardless of walkways
l_n = the nth left walkway's time value
r_n = the nth right walkway's time value
Give it a shot.
Challenge: Find a way to get your runtime to O(n log (n)).| Flag | PURGE - 1 Answer Can I change my internship from SDET to SDE?
Hello,
- andre.azevedo September 06, 2013
I just received an offer for an internship at Microsoft as SDET. At the moment the recruiter told me, I was so excited that I did not think that what I'd really want to to is a SDE internship (although it would be good to work as SDET as well).
My question is: Is it ok to e-mail my recruiter and ask her if I can change to a SDE internship?
Thank you!| Flag | PURGE - 0 Answers Solve this problem
We call an array of integers X of size N good if it can be partitioned into 2 arrays of size n/2, say p1[ ] and p2[ ], such that p1[0] + p2[0] = p1[1] + p2[1] = p1[2] + p2[2] = ... . Given an array Y, determine the size of its largest subset which is a good array.
- crCrush September 06, 2013
Input
The first line contains the integer N (≤ 100).
The next line contains N space separated integers, which are the elements of the array X.
Output
One number which is the size of the greatest subset as mentioned in the problem statement.
Example
Input:
6
1 4 2 3 8 10
Output:
4
Explanation:
The array {1,4,2,3} is good, since you can form p1[] = {1,2} and p2[] = {4,3}. (satisfying 1 + 4 = 2 + 3)| Flag | PURGE - 2 Answers Highest number less than or equal to the given number.
Hi all,
- anup.stackoverflow September 04, 2013
How can we find the highest number less than or equal to the given number?
One options is sorting + binary search.
Complexity (sorting ->nlogn, binary search->logn) = nlogn
is thr any better method?| Flag | PURGE - 4 Answers Previous large element
Hi ,
- abhi1988srivastava September 02, 2013
Given a sequence of n numbers, {a1; a2; · · · ; an}, for each element
ai
, 1 ≤ i ≤ n, nd the index of the rightmost element inside {a1; a2; · · · ; ai1} whose value is
strictly larger than ai
. If no element is larger than ai then output 0. In other words, nd for
each i
pi = max{j|0 ≤ j < i; aj > ai};
in which assume a0 = ∞
algorithm should work in O(n).
How to proceed?
What I thought : it seems to me as a upper triangular matrix and finding max for each column..
Correct me if I am wrong but how to do in O(n)?
Regards
Abhinav| Flag | PURGE - 0 Answers A Question regarding placements
I'm studying Computer Science and Engineering in a local college in Bangalore, India where there are no proper placements ( a few small time tech companies come there, offering small packages) Should i continue in that college? Or write a entrance exam again next year and study in some good college where placements and teaching is good. I don't feel like studying there. I want to prepare for exam and get some NIT, whats your opinion?
- Ayazm.140895 August 31, 2013| Flag | PURGE - 11 Answers DATABASE DESIGN
Suppose I have tables student(sid,name,cid) and course(cid,cname)
- 4m7u1 August 29, 2013
how do i make sure that a student can take more than one course without redundant rows (like
sid name cid
101 xyz 02,
101 xyz 03,
101 xyz 04...ie it would be redundant if each student takes a large number of courses).| Flag | PURGE - 0 Answers Data structures problem-solving web site
Hi,
- saad0105050 August 27, 2013
What are some best web resources on data structures problems and solutions (excluding video lectures, online courses, etc.)?
Some days ago I came across one such site, it listed many problems (grouped by context, e.g. array, liked list, etc.) and had solution code in java. However, I forgot the site's name and cannot find it by googling. Does anybody have any clue?
Thanks,
Saad| Flag | PURGE - 0 Answers can any body give the logic of this problem 15 puzzle problem
Method: getRandomNumbersForGrid()
- rajmuna084 August 23, 2013
public int[] getRandomNumbersForGrid() {
int arr[] = new int[15];
// write the logic for the method
return arr;
}
Hint:
The base class has a method called getRandomNumber() which will return some random integer
value.
Usage:
int randomInt = getRandomNumber(); // how to call this method…
Use this method to generate a random integer value. This can be any value and make sure you
trim it down to some value between 1 to 15.
Fill the array ‘arr’ with random numbers from 1 to 15 without repeating any of the
numbers. This will help in populating the grid with randomly generated numbers| Flag | PURGE - 2 Answers Need help with string reversal
I am trying to reverse a string recursively.But I am getting an exception.Below is my code :
- dummycoder August 21, 2013
void reverse_string(char *str,int start,int end)
{
char temp;
if(start>end)
return;
temp=str[end];
str[end]=str[start];
str[start]=temp;
reverse_string(str,++start,++end);
}
Please help me out some one.I am unable to understand the reason for this exception.| Flag | PURGE - 2 Answers Rejected due to lack of experience after technical interview
I recently had a series of technical interviews for a data scientist position. To the best of my knowledge I answered all of the questions correctly, however I was rejected and the reason given was my lack of practical experience. This seems strange considering my experience did not come up at all during the technical interview. I would find it hard to believe that they would be too "scared" to tell me that it is actually because of my answers to the technical questions. I guess what confuses me is that the technical interview was independent of my past experience, so if the rejection was due to my lack of experience then why even have the technical interview?
- alex1988 August 20, 2013| Flag | PURGE - 8 Answers interview question on commvault
make a search engine for limited text file in which if u print any word on that search engine than show that text file in which have more than that word and that text file is come at first place on search engine
- anilbatch2005 August 20, 2013
plz help me as soon as possible| Flag | PURGE