blue-j
BAN USER- 0of 0 votes
AnswersWrite jQuery code to alert a message box when you click on a paragraph with the content of paragraph.
- blue-j in United States for Global Foundation Services| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Front End Web Development - 1of 1 vote
Answer* Why Microsoft?
- blue-j in United States for Global Foundation Services
* What is Cloud Computing?
* How would you design a software application? Discussion about software and hardware requirements. How would you handle increase in load? How would you manage the increase in load without additional hardware?| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Behavioral - 0of 0 votes
AnswersWrite efficient code for Singleton class. I wrote the double-checked locking version. Then he asked for other approaches specifically to reduce the number of lines of code :-/
- blue-j in United States for Global Foundation Services| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Object Oriented Design - 0of 0 votes
AnswersYou have 2 character arrays. The arrays have characters ranging from a-z (all small letters).
- blue-j in United States for Global Foundation Services
1. Merge the two arrays
2. Sort the array
Perform the above in O(N)| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 0of 0 votes
AnswersConvert the matrix into a linked list (singly or doubly). Nodes have two pointers - right and down.
- blue-j in United States for Global Foundation Servicesa1-a2-a3-a4 | | | | b1-b2-b3-b4 | | | | c1-c2-c3-c4
| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 0of 0 votes
AnswersFind first two numbers whose sum equals a given number in infinite length (stream of numbers) singly linked list.
- blue-j in United States for Global Foundation Services| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 0of 0 votes
AnswersWrite HTML/CSS code to put odd images on left and even number images on right with some text content (basically float images).
- blue-j in United States for Global Foundation Services| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Front End Web Development - 0of 0 votes
Answers(Don't remember the exact wordings) You have 25 red balls, 47 green balls and 3 blue balls in a basket. What is the minimum number of balls you have to pick to make sure you have at least 2 balls of different colors?
- blue-j in United States for Global Foundation Services| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Brain Teasers - 0of 0 votes
AnswerDo you know about design patters? What is Singleton?
- blue-j in United States for Global Foundation Services| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Object Oriented Design - 0of 0 votes
AnswersOperating Systems (in windows):
- blue-j in United States for Global Foundation Services
* Difference between Process and Thread
* Deadlock
* Race condition| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Operating System
String sumBinary(String num1, String num2) {
// Indexes to start from
int i1 = num1.length() - 1;
int i2 = num2.length() - 1;
// characters at index
int b1 = 0;
int b2 = 0;
// sum character
int c = 0;
// sum index
int si = i1 > i2 ? i1 : i2;
// sum char array
char[] sum = new char[si + 1];
// carry
int carry = 0;
// iterate until both the strings are read
while(i1 >= 0 || i2 >= 0) {
b1 = 0;
b2 = 0;
if(i1 >= 0) {
b1 = ( (int) num1.charAt(i1) ) & 0x01;
}
if(i2 >= 0) {
b2 = ( (int) num2.charAt(i2) ) & 0x01;
}
// compute sum of bits
c = b1 + b2 + carry;
// compute carry
carry = c & 0x03;
carry = carry >> 1;
// sum bit
c = c & 0x01;
// put sum bit in the sum char array
sum[si] = (char) (c + 0x30);
i1--;
i2--;
si--;
}
return new String(sum);
}
class IcecreamStore {
Time machine1_lastDeparture;
Time machine2_lastDeparture;
Time machine3_lastDeparture;
public OrderOut makeIcecream(Time orderTime, int orderNum, int icecreamType) {
Time earliestAvailable = min(machine1_lastDeparture,
machine2_lastDeparture, machine3_lastDeparture);
OrderOut orderOut = new OrderOut();
if(earlistAvailable <= orderTime) {
orderOut.departureTime = orderTime
+ getTimeToMake(icecreamType);
}
else {
orderOut.departureTime = earlistAvailable
+ getTimeToMake(icecreamType);
}
updateMachine(earliestAvailable);
orderOut.totalTime = orderOut.departureTime - orderTime;
orderOut.orderNum = orderNum
return orderOut;
}
private Time getTimeToMake(int ice) {
if(ice == 0)
return new Time(15);
else
return new Time(45);
}
private updateMachine(Time t) {
// update the machine variable which has the lowest value with t.
// Because that machine will be used to make this order.
}
}
class OrderOut {
int orderNum;
Time departureTime;
Time totalTime;
}
Recursive approach will calculate same solutions multiple times. Consider using DP.
public HashSet<String> stairs(int n) {
ArrayList<HashSet<String>> prevPaths = new ArrayList<HashSet<String>>();
HashSet<String> st1 = new HashSet<String>();
st1.add("1");
if(n == 1) return st1;
prevPaths.add(st1);
HashSet<String> st2 = new HashSet<String>();
st2.add("11");
st2.add("2");
if(n == 2) return st2;
prevPaths.add(st2);
for (int i = 3; i <= n; i++) {
HashSet<String> sti = new HashSet<String>();
HashSet<String> sti_1 = prevPaths.get(1);
for(String subPath : sti_1) {
sti.add("1" + subPath);
sti.add(subPath + "1");
}
HashSet<String> sti_2 = prevPaths.get(0);
for(String subPath : sti_2) {
sti.add("2" + subPath);
sti.add(subPath + "2");
}
prevPaths.add(0, prevPaths.get(1));
prevPaths.add(1, sti);
}
return prevPaths.get(1);
}
You can use formula n(n-1)/2 to find starting number for nth row.
startNum = n(n - 1)/2 + 1, where n is the row number
void printTriangles(int n) {
int i = 1;
while(i <= n)
printRow(i++);
i--;
while(i > 0)
printRow(i--);
}
void printRow(int n) {
int startNum = n * (n - 1) / 2 + 1;
while(n > 0) {
cout << startNum++;
if(n > 1)
cout << " * ";
}
}
Could you please explain how can you represent next 32 cards in 5 bits, and then 4 bits, 3 bits and so on.. The cards are in random order. Assuming that you have to assign a code to each card and this code should be known to source and target how can you represent a card in less than 6 bits in your example? Also what will be the format of the stream? I would assume just a stream of bits with no stop word.
- blue-j February 24, 2015
Method 1:
better than O(n). O(b) where b = number of set bits.
Method 2:
O(1)
If character is 8-bit then use following. It can be extended for 32 bits.
This can be optimized even further but then it becomes less readable. From the book Hacker's Delight :-)
- blue-j June 19, 2015