codemonkey
BAN USER- -4of 4 votes
AnswersTwo sorted 2D arrrays, get the third one sorted
- codemonkey in United States
A = [["a", 1], ["b", 2]] sorted all elements have different names
B = [["a", 2], ["c", 3]] sorted
C = [["a", 3], ["b", 2], ["c", 3]] sorted| Report Duplicate | Flag | PURGE
Twitter Software Engineer / Developer - 0of 0 votes
AnswerSearch results shows short segments ("snippets") of results and highlights query terms.
- codemonkey in United States for Search
Look, for example, at a search for [buy apple ipad] in [tablet]:
http://www.search.google.com/search?find_desc=buy+apple+ipad&find_categ=tablet.
Only a part relevant to query is shown which is shorter than the entire result.
For this question you will write a function that finds the most relevant snippet for a document and highlights all the query terms that appear in the snippet (like the highlights you saw on the linked search page). It is up to you to define what constitutes a good snippet and how big the snippets will be.
Indicate highlights by surrounding the text to be highlighted with [[HIGHLIGHT]] ...
[[ENDHIGHLIGHT]].| Report Duplicate | Flag | PURGE
Yelp Software Engineer / Developer Algorithm - -1of 1 vote
AnswersSuppose there is an array with numbers :
- codemonkey in United States for Search
1, 14, 5, k, 4, 2, 54, k, 87, 98, 3, 1, 32
Output for this can be assuming k =20
1,14,5,4,2,3,1,k,k,54,87,98,32
Now sort this array in a way all k are in middle and all values on left of k are smaller (in any order) and on right are larger (in any order)
Note: k is an integer value within range of 1 - 32768
Follow up: Sorting is ok. what sorting you want to use ? still is sorting necessary ? are there any other approaches ?
Follow up: Used External array with 2 pointers and 3 pointers approach. They wanted more efficient solution.| Report Duplicate | Flag | PURGE
Yahoo Software Engineer / Developer Algorithm - 0of 0 votes
AnswersHow would you design an Excel sheet's Data structure. You need to perform operations like addition. The excel sheet is very sparse and is used to store numbers in the range 1-65K. Index for a cell is known.
- codemonkey in United States for Search| Report Duplicate | Flag | PURGE
Yahoo Software Engineer / Developer Algorithm - 0of 0 votes
AnswersHow to sort a 1000 GB file with ram size is 4 GB only. Which algorithm or data structure we need to use to sort these files?
- codemonkey in United States for Search
Follow Up: External sort is Ok... but how can you make this solution more efficient...
Follow Up 2: Ideal chunk size for external sort (I said 512 MB based on my experience with MS Word 2013, it can not load file size >512 MB)| Report Duplicate | Flag | PURGE
Yahoo Software Engineer / Developer Algorithm - 0of 0 votes
Answers3. Data structures. BST, Hash Maps their complexities,
- codemonkey in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 0of 0 votes
Answers4. Write Code: Find first unique character in an array.
- codemonkey in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 0of 0 votes
Answers2. Stack vs Heap memory allocation.
- codemonkey in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 0of 0 votes
Answers4. Write Code: Count number of set bits in an Integer
- codemonkey in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 0of 0 votes
Answers2. What is difference between overloading and overriding
- codemonkey in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 0of 0 votes
AnswersWrite Code: Find an integer array's maximum value. Trace code. Use Try/catch instead of return.
- codemonkey in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer
- 6 Answers PDF Copy of 5th Edition
I have already purchased the book from Flipkart... but i thought it would be handy if i can have a PDF copy of this for personal use only to read while travelling to university and in other cases.
- codemonkey March 21, 2012
Is there a way i can get the PDF copy , may be by producing the receipt of the book puchase.
That would be really really helpful.| Flag | PURGE
Updated the question. k is an integer value.
- codemonkey November 09, 2012Map Reduce is not a solution for this problem at all since we have a single node.
- codemonkey November 09, 2012Construct a tree binary tree considering of 1024 bottles... at lowest level we have 1 bottles.. now if we need to find only a single bottle that is poisoned we can do it in 10 tries i.e height of tree. drinks 512th bottle...256th bottle.. and so on.. just like divide and conquer... so it will min 10 chances...
- codemonkey October 06, 2012Can't we use a sort on initial input if we have them stored. then push them in decreasing order ?
if we already have the problem where we are randomly generating number than putting them in stack, we need to use atleast 3 stacks, and this problem will pretty much looks like Towers of Hanoi problem, and we can use a recursive approach to solve it.
Approach can be solving using O(n^2) approach. calculate distance between every 2 points and find the minimum distance pair.
Or in divide and conquer we can use highest coordinates/2 and divide the plane and keep doing it until we reach a set where we just have 2 points.. for every region calculate dist(min) and dist with its neighboring cells. this might be complicated to implement though.
yes marking the elements is a good technique. exactly what i have suggested
- codemonkey October 06, 2012hm yeah you are right about the 4th edition.. i could still find pdf copies using a single Google Search
- codemonkey March 22, 2012Select distinct (custid) from (custid,sum(expenses) as S from T order by S desc) and rownum<=5
- codemonkey March 21, 2012Algorithm @ en.wikipedia.org/wiki/Tic-tac-toe
- codemonkey March 21, 2012The user interface - this includes the address bar, back/forward button, bookmarking menu etc.
The browser engine - the interface for querying and manipulating the rendering engine.
The rendering engine - responsible for displaying the requested content. For example if the requested content is HTML, it is responsible for parsing the HTML and CSS & displaying on screen.
Networking - used for network calls, like HTTP requests. It has platform independent interface and underneath implementations for each platform.
UI backend - used for drawing basic widgets like combo boxes and windows. It exposes a generic interface that is not platform specific. Underneath it uses OS user interface methods.
JavaScript interpreter. Used to parse and execute the JavaScript code.
Data storage. This is a persistence layer. The browser needs to save all sorts of data on the hard disk, for examples, cookies.
select p1.id,p2.id
from person p1,person p2
where p1.momid=p2.momid
and p1.dadid=p2.dadid and p1.id <> p2.id
I will simply follow the algorithm..
while(number_of_element>=6)
{
arrayleast[3];
arraymax[3];
}
Once the complete array is traversed, simply multiply each element in a list with other numbers forming pairs of 3.
SO we have total 6*5*4 operations. and find the maximum of those . numbers involved in it are our answer.
findstr(char *sub, char *str)
{
if(sub>str || strlen(str)==0 || strlen(sub)==0) {return(-1);}
for(int i=0;i<strlen(str);i++)
{
if(sub[0]==str[i])
{
int k=0, flag=0;
for (int j=i;j<(i+strlen(sub))
{
if (sub[k]==str[i])
{
flag++;
}
k++;
}
if(flag==strlen(sub))
{
printf("substring found at index %d",i);
}
}
}
}
findstr(char *sub, char *str)
{
if(sub>str || strlen(str)==0 || strlen(sub)==0) {return(-1);}
for(int i=0;i<strlen(str);i++)
{
if(sub[0]==str[i])
{
int k=0, flag=0;
for (int j=i;j<(i+strlen(sub))
{
if (sub[k]==str[i])
{
flag++;
}
k++;
}
if(flag==strlen(sub))
{
printf("substring found at index %d",i);
}
}
}
}
A free list is a data structure used in a scheme for dynamic memory allocation. It operates by connecting unallocated regions of memory together in a linked list, using the first word of each unallocated region as a pointer to the next. It's most suitable for allocating from a memory pool, where all objects have the same size.
Free lists make the allocation and deallocation operations very simple. To free a region, one would just link it to the free list. To allocate a region, one would simply remove a single region from the end of the free list and use it. If the regions are variable-sized, one may have to search for a region of large enough size, which can be expensive.
can you explain in detail ?
- codemonkey November 09, 2012