Forum Posts
- 1 Answer Java front end developer interview questions
hello all, thanks in advance.
- j.laxmiprasanna September 11, 2014
Iam new to software industryhere in US, i am going to have my interview next week, feeling so nervous.
So could some please share their interview experiance and also type of questions i could expeect at my interview.
I am going to have interview for Java front end developer| Flag | PURGE - 1 Answer BitWise Operator
Hi All,
- sunil.vurity September 07, 2014
I have a question
A country has 25 states ( can vary) and based on population of each state give a color to that state.
for e.g
state1 population is 5000
state2 population is 10000
state3 population is 12000 and so on....
now im also given colors to assign based on population
population==5000 assign green
5000<population<10000 - blue
population==10000 assign orange
10000<population<15000 - yellow and so on up to 100,000 ( this is the max limit of population for a state )
I can give a solution where
Step 1: create a dictionary/hashtable to maintain colors based on population.
Step 2 : Read each country population ( iterate thru countries ) and lookup in hashtable and assign.
the above solution is bruteforce.
I was given a hint to use bitwise operator for this . Any thoughts how I can go about it ?
Thanks,| Flag | PURGE - 0 Answers data structure
this is c program to check balanced paranthesis using stack,
- rkc1.NITD September 05, 2014
i dnt know whats wrong it always showing balanced expression.
tell me what i am doing wrong.??#include<stdio.h>
void main()
{
char stk[50],exp[100];
int top=-1,i;
printf("enter an expression\n");
gets(exp);
for(i=0;exp[i]!='\0';i++)
{
if(exp[i]=='('|| exp[i]=='['||exp[i]=='{')
{
top++;
stk[top]=exp[i];
}
else
if(exp[i]=')')
{
if(stk[top]=='(')
top--;
}
else
{
printf("unbalanced exp\n");
break;
}
if(exp[i]=']')
{
if(stk[top]=='[')
top--;
}
else
{
printf("unbalanced exp\n");
break;
}
if(exp[i]='}')
{
if(stk[top]=='{')
top--;
}
else
{
printf("unbalanced exp\n");
break;
}
}
if(top==-1)
printf("exp is balanced\n");
else
printf("exp is not balanced\n");
}| Flag | PURGE - 0 Answers 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.
- pvpkiran September 01, 2014
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| Flag | PURGE - 1 Answer LinkedList question
The code below is from the book.
- rsun2014 August 31, 2014
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?| Flag | PURGE - 1 Answer Minimize the moves
This is an online written test.
- Priyanka August 26, 2014
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.| Flag | PURGE - 0 Answers Design a Shopping cart?
it is an interview question:
- User August 25, 2014
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?| Flag | PURGE - 4 Answers linked list problem
it is c program for inserting a node at the beginning of link list,..plz fix the errors in this program.
- rkc1.NITD August 23, 2014
#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;
}| Flag | PURGE - 3 Answers Is the "reverse a string" solution (1.2) pg 73 correct?
Hello,
- nmartin867 August 20, 2014
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!| Flag | PURGE - 0 Answers path/height of tree like structure
Consider the following class definition:
- newbee August 19, 2014
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.| Flag | PURGE - 0 Answers 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.
- pavank140 August 13, 2014
1.rotation
2.querying
3.updation
and print the ouput for the above types...| Flag | PURGE - 0 Answers 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 follow-up. How long does Amazon take to reveal personal interview results?
- glensmooth August 10, 2014| Flag | PURGE - 0 Answers 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 follow-up. How long does Amazon take to reveal personal interview results?
- glensmooth August 10, 2014| Flag | PURGE