Forum Posts

Algorithm
There is a rope on which you will put clothes to dry. And each cloth is of different length and their starting position on the cloth is also different. Once all the clothes are put on the rope. we have to find out how many clothes are visible if i look it from top.
You are given two inputs.
1. length of the rope
2. And a list of Cloth Objects.
List<Cloth>
Cloth class is defined like this
class Cloth{
int initial Position,
int clothLength
}
for example if i am given rope length of 7
and List of cloth objects which has 3 Cloth Objects C1, C2, C3
C1.initialPosition = 0
C1.clothLength = 5(this cloth will cover from 0 to 5)
C2.initialPosition = 2
C2.clothLength = 2 (this cloth will cover from 2 to 4. since length of cloth =2)
C3.initialPosition = 1
C3.clothLength = 5 (this cloth will cover from 1 to 6. since length of cloth =5)
So with this. we can only see Cloth 1 and Cloth 3. So the output should be 2
Imagine the rope like this.
....................................................................
0 1 2 3 4 5 6 7 
LinkedList question
The code below is from the book.
public static void deleteDups(LinkedListl\lode n) {
......(many lines)
while(n.next != null)
n = n.next;
.....
}
In this situation, LinkedListNode is a class,
so if you give LikedListNode n to this method, this method receive the node n rather than the copy of n.
when using n = n.next, it change the head of the LinkedList, am I right? 
Minimize the moves
This is an online written test.
Please solve it.
You have a sequence of d[0] , d[1], d[2] , d[3] ,..,d[n]. In each move you are allowed to increase any d[i] by 1 or 2 or 5 i:0 to n .What is the minimum number of moves required to transform the sequence to permutation of [1,2,3,..,n] if it's possible else return 1.
Constraint: 1<=n<=1000
nput:
First Line will have no of elemnts
Second Line on. elements will be present
Ex: 5
1
1
3
2
1
Output:
As no of elements are 5, all permutation can be {1, 2, 3, 4, 5} .
To convert input to get all possible permutation i.e {1, 2, 5, 4, 3},
no of moves will be 4.
Hence output would be 4. 
Design a Shopping cart?
it is an interview question:
1. Design a shopping cart.
2. How the tables are stored(different tables structure)
3. How do you use http sessions?
4. Password storage rather than storing in DB.
5. How do you normalize tables?
6. Design in keeping view of using design patterns?
7. what all design patterns are used and explain? 
Zulily Interview
Does anyone happen to know what to expect for Zulily phone interview?

linked list problem
it is c program for inserting a node at the beginning of link list,..plz fix the errors in this program.
#include<stdio.h>
#include<stdlib.h>
struct node
{
int data;
struct node* next;
};
struct node* head;
void insert(int x)
{
struct node* temp=(node*)malloc(sizeof(struct node));
temp>data=x;
temp>next=NULL;
head=temp;
if(head!=NULL)
{
temp>next=head;
head=temp;
}
else
{
temp>next=head;
head=temp;
}
void print()
{
struct node* temp=head;
printf("list is: ");
while(temp!=NULL)
{
printf("%d",temp>data);
temp=temp>next;
}
printf("\n");
}
int main()
{
head=NULL; /*empty list*/
int n,i,x;
printf("how many no you want to add?\n");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("enter the no.:\n");
scanf("%d",&x);
insert(x);
print();
}
return 0;
} 
Is the "reverse a string" solution (1.2) pg 73 correct?
Hello,
I just picked up "Cracking the Coding Interview" and I started working through the first chapter's questions. I typed in the author's solution to question 1.2 and I can't see how this would work. The solution attempts to reverse a string, in place, by decrementing a pointer positioned at the last char and incrementing a pointer at the beginning of a string until the pointers meet in the middle.
The solution is as follows:
{{#include <stdio.h>
void reverse(char *str){
char *end = str;
char tmp;
while(*end){
++end;
}
end;
while(str < end){
tmp = *str;
*str++ = *end;
*end = tmp;
}
printf("str: %s\n",str);
printf("end: %s\n",end);
}
}}
I tested this solution like so:
{{int main(int argc, const char * argv[])
{
char mystring[] = "hello";
reverse(mystring);
return 0;
}
}}
This does not work. The issue is with condition in the while loop. Control is returned from the loop when both "str" and "end" are equal. In my above example the printf statements will output
str: leh
end: leh
This makes sense. It seems that the condition is expecting the values of str & end to be ordinal positions ?? Am I over looking something obvious?
Thanks! 
path/height of tree like structure
Consider the following class definition:
class Node {
List<Node> node;
void addChild (Node testNode);
}
Assume you have a node object like above. This node object can contain a child node object. Assuming you are given one of these objects, write a function to determine the maximum path length from the root node to the most distant remote node.
Its not exactly tree as it doesnt have any left and right information but it has nodes on both sides. 
I got selected in Microsoft se...
I got selected in Microsoft services global delivery for associate consultant role.how many days it will take time to release after hr asking for documents .
my exp 2.7+
interview held on 10 aug 2014 and she asked documents on 12 .please reply me when can I expect offer 
oracle 10 G job
To schedule a job which will run in weekdays between 3pm to 5pm , in a interval of 15min.
(its for oracle 10g so it doesn't support schedular
** without using repeat_interval.) 
coding
Given an array of numbers arrange it in the form of a single number such that the concluded number is the maximum. e.g. given : 99,8,76,45,66,9,7,33,5,42 O/P : 99987766654233

Resources to learn about nary tree.
Given a nary tree, Convert it into an array and return it. Construct the same nary tree from that array again.
Looking for C implementation for creation and traversal of nary tree. 
Algorithm
how to make all the elements in an array to a common element of the array in minimum time ?

c/c++ source code required
your are given square matrix of dimensions N. Let this matrix be called A.Your task is to rotate A in clockwise direction in s degrees,where s is the angle of rotation.on the matrix there will be three types of operations viz.
1.rotation
2.querying
3.updation
and print the ouput for the above types... 
Microsoft online technical screen
Does anyone happen to know what Microsoft asks in its online technical screen? Its a 45 mins screening test, and not a phone screen. Appreciate any help.

How long after Amazon interview?
I appeared for a personal interview at Amazon, after clearing phone interview. It's been 5 business days (if I don't count the interview day) and I haven't heard anything back. There was also not response from an immediate followup. How long does Amazon take to reveal personal interview results?

How long after Amazon interview?
I appeared for a personal interview at Amazon, after clearing phone interview. It's been 5 business days (if I don't count the interview day) and I haven't heard anything back. There was also not response from an immediate followup. How long does Amazon take to reveal personal interview results?

How long after Amazon interview?
I appeared for a personal interview at Amazon, after clearing phone interview. It's been 5 business days (if I don't count the interview day) and I haven't heard anything back. There was also not response from an immediate followup. How long does Amazon take to reveal personal interview results?

Unable to post SumoLogic StartUp company interview questions, if anyone can post on my behalf will be thank ful
Unable to post SumoLogic StartUp company interview questions, if anyone can post on my behalf will be thank ful
Question 1 :
Kindly find the question below:
Design a data structure which has following operations:
1. void add(e)
2. void delete(e)
3. boolean contains(e)
4. e getRandom()
5. e getMostRecent()
All operations should be preferably O(1)
Answer :
public class ValidateData
{
private HashMap<Object, Integer> hashMap = new HashMap<>();
private ArrayList<Object> list;
public ValidateData()
{
hashMap = new HashMap<>();
list = new ArrayList<>();
}
public void insert(Object object)
{
int index = list.size();
hashMap.put(object, index);
list.add(object);
}
public boolean contains(Object object)
{
return hashMap.containsKey(object);
}
public void delete(Object object)
{
if (hashMap.containsKey(object))
{
int index = hashMap.get(object);
int end = list.size()  1;
Object o = list.get(end);
list.set(index, o);
list.remove(end);
hashMap.put(o, index);
hashMap.remove(object);
}
}
public Object getRandom()
{
Random rand = new Random();
int index = rand.nextInt(list.size());
System.out.println(list.get(index));
return list.get(index);
} 
brain teaser
you have a random sequence of number from 110, 2 players and u being the first player ! Each player can only choose a number close to the one that is already chosen or the last number . The winner is the one that has a larger total ( in this case above 28 since the total of the numbers is 55 ) How can u ensure u always win??
example
4 6 3 7 10 2 9 8 5 1  You have this starting sequence
I am player one and I choose 4
player 2 can choose either 6 or 1
Assuming he choose 6 I can either choose 3 or 1 and so on...
I chose 3 and player 2 chose 7
I chose 10 and player 2 chose 2
I chose 9 and player 2 chose 8
I chose 5 and player 2 chose 1
my total :4+3+10+9+5= 31
Player 2 : 6+7+2+8+1= 24
therefore I won.
How can we generate a winning sequence every time even though the numbers r changing?