30 Day Risk-Free Guarantee:
100% money back if you're unsatisfied.
Book (308 Pages):
  • 150 Programming Interview Questions and Solutions
  • Five Proven Approaches to Solving Tough Algorithm Questions
  • Ten Mistakes Candidates Make -- And How to Avoid Them
  • Steps to Prepare for Behavioral and Technical Questions
  • Interview War Stories: A View from the Interviewer's Side
  • Book Preview and More Info

Video (One Hour):
  • Watch CareerCup's founder perform a totally unscripted technical interview of a candidate.
  • Overview of what interviewers look for in software engineering jobs.
  • Technical questions with white-boarding coding where the candidate does well - and struggles.
  • Interviewer reviews with what went well and poorly.
  • Video Preview and More Info

Resume Review (24 - 48hr)
  • Get your resume reviewed by a trained engineering interviewer. More Info
All Products / Services


Express Prep Package (Book)
$29.99 for e-book | $32.45 for paperback
Buy E-Book Buy on Amazon


Standard Prep Package (E-Book & Video)
Emailed Instantly | $39.99
Buy Standard

Elite Prep Package (E-Book, Video & Resume)
Emailed Instantly | $99.99
Buy Elite
 



Imagine there is a square matrix with n x n cells. Each cell is either filled with a black pixel or a white pixel. Design an algorithm to find the maximum subsquare such that all four borders are filled with black pixels;

32


nunbit romance on June 11, 2007 |Edit | Edit

Could you clarify the question a bit more? Do the number of black pixels and white pixels have to be equal? Also, are subsquared filled with one color only?

Anonymous on October 10, 2007 |Edit | Edit

(n-1) x (n-1) will be the sub square

sb on October 14, 2007 |Edit | Edit

I am thinking; consider we have the nxn in an array a[][], assume a[i][j].color gives us the color.
1. Max spiral size ms = 0;
1. For each element starting from a[0,0], until last;
2. Assume a funtiona Spiral which does the followig:
The moment we hit a white color cell we will try to go as far(distance d) to the right and go down d and go up distance d in a spiral fashion. We continue until the spiral hits the smallest possible spiral updating localms, in the process if we hit a black cell we set localms =0 and quit,else return localms.
3. If localms > ms then ms = localms
3. If Go to step 1 with the next element.
4. return ms

If the actual sub square is required in terms of the array indices (left top/right bottom pair), we need to store that too in function spiral.

KSD on October 19, 2007 |Edit | Edit

I guess the spiral has an issue.. The above method will help u in finding squares within squares... But what about a sub-square on left/right corner?

______________
| | |
| | |
|____| |
| |
| |
|_____________|

______________
| |
| _______ |
| | | |
| | | |
| |______| | ====> Your Spiral model will generate this.
|_____________|

Raghu on October 30, 2007 |Edit | Edit

use dynamic programming.
keep two values right and down that tells how many consecutive black pixles are in that direction including the current pixel.
Compute this using bottom up approach.
Then, use these values to compute the maximum square length at each pixel. Should run in O(n*n) time and memory.
What do u guys think?

Vel on November 01, 2007 |Edit | Edit

Good idea, Raghu !
I guess you need left and up values as well, It would be when your algo is crunching in the middle of the matrix. but ya .. it would work in O(n^2) space and time ... but thats acceptable .. n^2 time is definitely needed to read every pixel... its linear in terms of the number of cells.

Vel on November 01, 2007 |Edit | Edit

Assume the matrix to be a binary tree, where each cell is a node connected to 2 other nodes (down & right). Do a DFS based on this tree structure and determine borders.
1. keep a count of consecutive black pixels along one direction(if its less than the max found so far, then forget it).. else its a potential candidate, so explore other borders
2. still dont know how to avoid redundancy in checking ..
3. one spl case would be that if you find a square of side n/2 .. u can stop ..! :D .. pretty obvious !

... i know its kinda vague .. but seems like the right direction.

Lee on January 14, 2008 |Edit | Edit

using a devide and counter method could yield between O(n*lgn) and O(n^2);
FindMaxSquare(matrix,1,n){
sqr1=FindMaxSquare(matrix,1,n/2);
sqr2=FindMaxSquare(matrix,n/2+1,n);
borderLength=max(sqr1.borderLength,sqr2.borderLength);
sqr3=FindMaxSqaureAlongAxis(n/2,borderLength+1);
if(sqr3!=null)return sqr3;
else return max(sqr1,sqr2);
}
master theorem T(n)=2T(n/2)+f(n);
here f(n) is the complexity of FindMaxSqaureAlongAxis, so if we could prove that complexity of FindMaxSqaureAlongAxis is between O(n) and O(n^2), then the total time we need is between O(n*lgn) and O(n^2).
Complexity of FindMaxSqaureAlongAxis is O(borderLength*n), since borderLength could be a constant, or could be proportional to n, so O(n)=<O(borderLength*n)=<O(n^2). done

vandna on February 08, 2008 |Edit | Edit

I think we will use dynamic programming here.I agree with raghu.

let the size of square be N.
pseudocode:

for each cell
{
calculate the black cell along its right.Let it ne Nr.
Calculate the white cells along downside.
Let it be Nd
length = Min(Nr,Nd)
for i =1 to length
{
check the subcell i*i has blackborder
if yes.
max=cell id and i
}
}
return Max

It will have complexity of order N^N.

qimi on October 30, 2009 |Edit | Edit

why is this O{n^2}?

for each cell // n
{
calculate the black cell along its right.Let it ne Nr. //n
Calculate the white cells along downside. Let it be Nd //n
length = Min(Nr,Nd) // 1
for i =1 to length //n
{
check the subcell i*i has blackborder //n^2
if yes.
max=cell id and i
}
}
return Max

It should be O(n*(n+n+1+n*n^2)) = O(n^4)???

Anonymous on February 08, 2008 |Edit | Edit

also check max..at every loop

if i < max
do not store
else max = new max

The Hercules on March 03, 2008 |Edit | Edit

Apply dynamic programming to compute Max length for row & columns
1) Initialize
maxRowLen[ k ] [ n-1 ] = (arr[ k ][ n -1 ] == 0 ?1:0)
maxColLen[ n-1 ] [ k ] = (arr[ n-1 ][ k ] == 0 ?1:0)

For each element in arr[k][j] (k = n-2 to 0) (j = n-2 to 0)

2) if arr[ k ] [ j ] == 1
maxRowLen[ k ] [ j ] = 0
3) else // i.e arr[ k ] [ j ] == 0
maxRowLen[ k ][ j ] = maxRowLen[k][j+1] + 1

Compute Max length for Column
4) if arr[ k ] [ j ] == 1
maxLen[ k ][ j ] = 0
5) else // i.e arr[j] == 0
maxColLen[ k ][ j ] = maxColLen[k+1][j] + 1

6) maxSqLen = 0

Now iterate either of max length row or max length col & for each (either of) maxRowLen or maxColLen ---
Lets take maxRowLen
7) lenOfSquare = Minimum( maxRowLen[k][j], maxColLen[k][j] )
8) if lenOfSquare > maxSqLen
9) Now, check if a square is formed
if( maxColLen[ k ][ j+ lenOfSquare ] == lenOfSquare &&
maxRowLen[ k + lenOfSquare ][ j ] == lenOfSquare )
{
maxSqRowStart = k;
maxSqColStart = j;
maxSqLen = lenOfSquare ;
}

Space - 2 dimension array for maxRolLen & maxColLen i.e O(2 * N square )
Time - O( 2 * N square )
1) Compute maxRowLen & maxColLen for each element of arr[n * n] +
2) Compute if square with max len is formed for each element (either of) maxRowElem or maxColLen

Anonymous on March 22, 2008 |Edit | Edit

For subsquare, N^2 is enough. What if it is not subsquare?

gauravk.18 on April 07, 2008 |Edit | Edit

The output should be a subsquare surrounded by all black pixels. This can be done by keeping a list of all white squares and running BFS from each white square. The white squares can not be from first row or column and last row or column. When running BFS pick up any one node and travel level by level eliminating branches that cannot satisfy the constraints. Also eliminate these nodes from the list of white squares. If you are able to find an enclosed boundary then just check if the enclosed boundary has k*k dimensions.This can be done by keeping track how much we have moved in y direction and x direction.

hp on April 15, 2008 |Edit | Edit

at least n^3

Anonymous on May 25, 2008 |Edit | Edit

Using Dynamic programming, can it be done like...
for each cell
n = calculate size of square it's forming using black border
SquareSize = (n-2);
if(maxSquareSize < SquareSize)
maxSquareSize = SquareSize;

print "maxSquareSize"

MaxSquare on May 25, 2008 |Edit | Edit

Using Dynamic programming, can it be done like...
for each cell
n = calculate size of square it's forming using black border
(for this need to check all 4 sides of square so that they have
equal nos. of black pixels)
O->->->->->
| |
| | here n = 5;
| | squareSize = 3
| |
| |
->->->->->

SquareSize = (n-2);
if(maxSquareSize < SquareSize)
maxSquareSize = SquareSize;

print "maxSquareSize"

MaxSquare on May 25, 2008 |Edit | Edit

formatting has ruined the square I am trying to display. Consider right vertical edge such that width = height = 5

Does anyone consider this case ? on June 12, 2008 |Edit | Edit

_ _ _ _
| /\ |
| / \ |
| / \ |
|/ \|
|\ /|
| \ / |
| \ / |
|_ _\/_ _|

previous post - formatting screw up on June 12, 2008 |Edit | Edit

_ _ _ _
| /\ |
| / \ |
| / \ |
|/ \|
|\ /|
| \ / |
| \ / |
| \/ |
- - - -

XYZ on September 10, 2008 |Edit | Edit

The easiest and O(n~n*n)way is:
Look for pure white subsqures instead of black frames.
------------------------------
Initialization:MaxLength=0;
------------------------------
step 1: for every cell, if cell=white go to step 2
------------------------------
step 2: take the current cell as the leftup corner of the subsqure, and length=1+MaxLength, is the subsqure pure white? If yes, go to step 3, else go to step 1;
------------------------------
step 3: is the squre surrounded by black frame? If yes,MaxLength++, and go back to step2; If no, go back to step 1.

XYZ on September 10, 2008 |Edit | Edit

so the size of possible white subsqures should be
0, 4=2*2, 9=3*3, 16=4*4.

Greenskid on December 24, 2008 |Edit | Edit

I can think of 2 methods. One is a simple to implement brutish method, while the other is more efficient but harder to implement.

Method 1: Simply test for sub-squares starting with S (length of side) = N, and continue till S = 2 i.e. S = N -> 2. For each S test each pixel in the matrix as the top corner of S. This is O(n^3), but it is simple to understand and gauranteed to work for complex configurations.

Method 2: As some have already mentioned, one can go through the matrix keeping a list of horizontal black lines (only need to store to coords - the start and end of the line). Then do similar to get a list of verticle lines. Note that one has to keep every single line and not just the max length lines because there are various combinations of lines that can form a square - Note: horizontal lines and verticle lines may intersect each other to form a square that is smaller then the length of each individual line. So from here I am not sure how to easily look at intersection points to identify the larger square.

I like my method 1 because it is simple and given be visually animated to show that it is scanning correctly.

nchikkam on December 31, 2008 |Edit | Edit

there is an O(n^2) algo with O(n^2) space.

Anonymous on February 12, 2009 |Edit | Edit

The answer is here: http://discuss.joelonsoftware.com/default.asp?interview.11.445656.19

Tdemfreema on October 22, 2009 |Edit | Edit

therapy for elderly <a href=http://blogcastrepository.com/members/Phentermine-Online-w69m.aspx>phentermine diet pills best price</a> The absolute bioavailability of saquinavir administered as FORTOVASE has not been assessed. However, following single 600-mg doses, the relative bioavailability of saquinavir as FORTOVASE compared to saquinavir administered as INVIRASE was estimated as 331% (95% CI: 207% to 530%). The absolute bioavailability of saquinavir administered as INVIRASE averaged 4% (CV 73%, range: 1% to 9%) in 8 healthy volunteers who received a single 600-mg dose (3 x 200 mg) of INVIRASE following a high-fat breakfast (48 g protein, 60 g carbohydrate, 57 g fat; 1006 kcal). In healthy volunteers receiving single doses of FORTOVASE (300 mg to 1200 mg) and in HIV-infected patients receiving multiple doses of FORTOVASE (400 mg to 1200 mg tid), a greater than dose-proportional increase in saquinavir plasma concentrations has been observed.
geriatric doctors <a href=http://www.wikipatterns.com/users/viewuserprofile.action?username=phentermine+fda+drugs>phentermine intravenous</a> Serious adverse events have been reported in concomitant use of methylphenidate with clonidine, although no causality for the combination has been established. The safety of using methylphenidate in combination with clonidine or other centrally acting alpha-2-agonists has not been systematically evaluated.
usa drug <a href=http://vilinet.communityserver.com/members/Tramadol-Online-b69m.aspx>tramadol cod cst</a> Usually, the more recent infection stems from a strain of bacteria different from the infection before it--a separate infection. Even if several UTIs in a row are due to E. coli, slight differences in the bacteria indicate distinct infections.
taking pills <a href=http://forums.acdjapan.com/index.php?showuser=3644>cialis for diabetics</a> Gemzar plus cisplatin versus cisplatin: This study was conducted in Europe, the US, and Canada in 522 patients with inoperable Stage IIIA, IIIB, or IV NSCLC who had not received prior chemotherapy. Gemzar 1000 mg/m2 was administered on Days 1, 8, and 15 of a 28–day cycle with cisplatin 100 mg/m2 administered on Day 1 of each cycle. Single–agent cisplatin 100 mg/m2 was administered on Day 1 of each 28–day cycle. The primary endpoint was survival. Patient demographics are shown in Table 5. An imbalance with regard to histology was observed with 48% of patients on the cisplatin arm and 37% of patients on the Gemzar plus cisplatin arm having adenocarcinoma.
drug-drug interactions <a href=http://sharepointmx.mvps.org/members/Tramadol-Online-o69m.aspx>tramadol cod 180 prescription</a> The optimal therapy for neonates with AIS or CVST has not been determined. Thrombolytic therapy has been used for peripheral thrombi in neonates but rarely for neonatal CVST, so neither its safety nor its effectiveness has been ascertained in these patients. Neither unfractionated heparin (UFH) nor low-molecular-weight heparin (LMWH) is used widely in children with perinatal AIS, although children with severe prothrombotic disorders or with cardiac or multiple systemic thrombi may benefit. No major complications occurred in preliminary studies of LMWH in neonates with CVST,<>09] but it is not clear whether anticoagulation is beneficial in these neonates, except in the setting of multiple thrombosed sinuses and radiological evidence of propagating thrombosis despite supportive therapy. Case reports also have described the use of antithrombin concentrate<>10]<>11] and protein C concentrate<>12] to prevent venous thrombosis in neonates with congenital or iatrogenic coagulation factor deficiencies.
physicians associates <a href=http://www.design21sdn.com/people/38080>cialis professional formulation</a> Severe reactions which may require emergency measures may take the form of a cardiovascular reaction characterized by peripheral vasodilatation with resultant hypotension and reflex tachycardia, dyspnea, agitation, confusion and cyanosis progressing to unconsciousness. Or, the histamine-liberating effect of these compounds may induce an allergic-like reaction which may range in severity from rhinitis or angioneurotic edema to laryngeal or bronchial spasm or anaphylactoid shock.
abbreviation for symptom <a href=http://www.chatarea.com/aubreyblaket>buy generic tramadol by</a> In April, 2009, an outbreak of a new strain of the influenza A virus H1N1, or swine flu, started in Mexico City. Alarming health officials around the world was the fact that H1N1 seemed to be rapidly spreading, plus there were several deaths reported as well in young, previously health people. As of May 6, 2009, Mexico has confirmed over 800 cases of H1N1 and 22 other countries have reported outbreaks as well for a worldwide total reported cases of just over 1500. However, more recent reports have been more restrained than the initial ones and there is no apparent evidence of a pandemic, plus the virus, in most cases, seems to cause milder-than-expected flu symptoms. Also, its rate of spread seems to be no more than that of our typical seasonal flu.
doctors company <a href=http://community.midwiferytoday.com/members/Tramadol-FDA-Drugs.aspx>can cats take tramadol</a> Epinephrine, also called adrenaline, is the medication of choice for treating an anaphylactic reaction. It works to reverse the symptoms and helps to prevent its progression. Epinephrine is available by prescription as a self-injectable device (EpiPenВ® or TwinjectВ®).
anxiety disorder <a href=http://vilinet.communityserver.com/members/Cialis-Online-469m.aspx>is cialis dangerous</a> A procedure called coronary angioplasty (also called balloon angioplasty) may be tried. During this procedure, a thin tube with a balloon or other device on the end is threaded through a blood vessel in your groin (upper thigh) or arm up to the narrowed or blocked coronary artery. Once in place, the balloon is inflated to push the plaque against the wall of the artery, widening the artery and restoring the flow of blood through it. In many cases, after the initial balloon angioplasty, a tiny mesh tube called a stent is inserted permanently in the area to keep the artery open.
murder <a href=http://forums.acdjapan.com/index.php?showuser=3642>tramadol 300mg</a> Patients suffering from psychotic disorders, schizophrenia, or confusional states should be treated cautiously with LIORESAL INTRATHECAL and kept under careful surveillance, because exacerbations of these conditions have been observed with oral administration.
hydrocortisone tablets <a href=http://blogcastrepository.com/members/Phentermine-Online-s69m.aspx>phentermine alkaline</a> Oxycodone may impair the mental and/or physical abilities required for the performance of potentially hazardous tasks such as driving a car or operating machinery. The patient using TYLOX should be cautioned accordingly.
light therapy for seasonal affective disorder <a href=http://www.wikipatterns.com/users/viewuserprofile.action?username=adipex+consumer+drug+resources>online weight loss rx adipex</a> In some cases, your doctor may refer you to a cardiac rehabilitation (rehab) program. These programs can help you recover through supervised physical activity and education on how to make choices that reduce your risk for future heart problems and help you get back to your regular lifestyle after surgery.
prescribe <a href=http://community.midwiferytoday.com/members/Tramadol-FDA-Drugs.aspx>nm tramadol regulation</a> Pregnancy: Pregnancy Category C. Econazole nitrate has not been shown to be teratogenic when administered orally to mice, rabbits or rats. Fetotoxic or embryotoxic effects were observed in Segment I oral studies with rats receiving 10 to 40 times the human dermal dose. Similar effects were observed in Segment II or Segment III studies with mice, rabbits and/or rats receiving oral doses 80 or 40 times the human dermal dose.
formulary drugs <a href=http://www.webjam.com/phentermine_for_patients>is phentermine a prescription drug</a> The most effective proven treatments for ROP are laser therapy or cryotherapy. Laser therapy "burns away" the periphery of the retina, which has no normal blood vessels. With cryotherapy, physicians use an instrument that generates freezing temperatures to briefly touch spots on the surface of the eye that overlie the periphery of the retina. Both laser treatment and cryotherapy destroy the peripheral areas of the retina, slowing or reversing the abnormal growth of blood vessels. Unfortunately, the treatments also destroy some side vision. This is done to save the most important part of our sightВ—the sharp, central vision we need for "straight ahead" activities such as reading, sewing, and driving.
community medicine <a href=http://www.webjam.com/cialisjl73>cialis side eefects</a> Following intravenous dosing in pediatric patients age 10-14 years, plasma half-life was shorter than in adults (1.5 hours vs. 2.0 hours in adults). In the same population following inhalation of budesonide via a pressurized metered-dose inhaler, absolute systemic availability was similar to that in adults.
crazy pills <a href=http://forums.autosport.com/index.php?showuser=58917>cialis extended release</a> Symptoms of post-polio syndrome include fatigue, slowly progressive muscle weakness, muscle atrophy, fasciculations, cold intolerance, and muscle and joint pain. These symptoms appear most often among muscle groups affected by the initial disease. Other symptoms include skeletal deformities such as scoliosis and difficulty breathing, swallowing, or sleeping. Symptoms are more frequent among older people and those individuals most severely affected by earlier disease.
research medicine <a href=http://www.webjam.com/tramadol_drug_information>sandbox test tumb cod tramadol</a> Ceftriaxone is excreted via both biliary and renal excretion (see <>section-4 CLINICAL PHARMACOLOGY]). Therefore, patients with renal failure normally require no adjustment in dosage when usual doses of Ceftriaxone Injection, USP are administered, but concentrations of drug in the serum should be monitored periodically. If evidence of accumulation exists, dosage should be decreased accordingly.
symptoms for ovarian cancer <a href=http://blogcastrepository.com/members/Phentermine-Online-s69m.aspx>phentermine tablets 30mg</a> ECG parameters were investigated in a double-blind, placebo-controlled, 24-hour post dose continuous monitoring, crossover study conducted in 47 subjects <>4 healthy volunteers and 23 patients with coronary artery disease (CAD)] designed to evaluate the effect of 0.2 mmol/kg MULTIHANCE on ECG intervals, including QTc. Results of the analyses indicate that average changes in QTc values compared with placebo were minimal (&lt; 5 msec). For most individual subjects changes in QTc values were less than 20 msec and evenly distributed between increases and decreases of the same magnitude. QTc prolongation between 30 and 60 msec were noted in 20 subjects (9 healthy volunteers and 11 CAD patients) who received MULTIHANCE vs. 11 subjects (6 volunteers and 5 CAD patients), who received placebo. Prolongations ≥61 msec were noted in 6 subjects (2 normal volunteers and 4 CAD patients) who received MULTIHANCE and in 3 subjects (0 volunteers and 3 CAD patients) who received placebo. None of these subjects had associated malignant arrhythmias.
cimetidine tablets <a href=http://forums.autosport.com/index.php?showuser=58912>tramadol with fluoxetine</a> Barrett's esophagus has no cure, short of surgical removal of the esophagus, which is a serious operation. Surgery is recommended only for people who have a high risk of developing cancer or who already have it. Most physicians recommend treating GERD with acid-blocking drugs, since this is sometimes associated with improvement in the extent of the Barrett's tissue. However, this approach has not been proven to reduce the risk of cancer. Treating reflux with a surgical procedure for GERD also does not seem to cure Barrett's esophagus.
generic music <a href=http://forums.autosport.com/index.php?showuser=58918>but cialis in us</a> The following noncontraceptive health benefits related to the use of oral contraceptives are supported by epidemiological studies which largely utilized oral-contraceptive formulations containing doses exceeding 0.035В mg of ethinyl estradiol or 0.05В mg of mestranol.
drug deal <a href=http://forums.acdjapan.com/index.php?showuser=3641>dog pain medication tramadol</a> 4. The percents becoming pregnant in columns (2) and (3) are based on data from populations where contraception is not used and from women who cease using contraception in order to become pregnant. Among such populations, about 89% become pregnant within one year. This estimate was lowered slightly (to 85%) to represent the percent who would become pregnant within one year among women now relying on reversible methods of contraception if they abandoned contraception altogether.
drugstores <a href=http://szdg.lpds.sztaki.hu/szdg/view_profile.php?userid=34467>forum skin blister phentermine purchase online</a> Following is a list of treatment-emergent adverse events reported by patients treated with CHANTIX during all clinical trials. The listing does not include those events already listed in the previous tables or elsewhere in labeling, those events for which a drug cause was remote, those events which were so general as to be uninformative, and those events reported only once which did not have a substantial probability of being acutely life-threatening.
supplements herbal <a href=http://szdg.lpds.sztaki.hu/szdg/view_profile.php?userid=34469>what does tramadol do</a> The Endocrine glands are ductless glands. Their internal secretions (hormones) enter the blood. The physiologist's Endocrine System includes endocrine glandular tissues and isolated endocrine cells in organs not primarily identified as endocrine glands.
macrobid prescribing information <a href=http://www.chatarea.com/landonvanessat>tramadol apap opinion</a> Diffuse hyperplastic perilobar nephroblastomatosis (DHPLN) is a condition in which abnormal tissue grows on the outer part of one or both kidneys. Children with DHPLN are at risk for developing a type of Wilms tumor that grows quickly. Frequent follow-up testing is important for at least 7 years after the child is diagnosed with DHPLN.
harris roach tablets <a href=http://www.webjam.com/cialisjl73>cialis family</a> The precise mechanism through which fluticasone propionate affects allergic rhinitis symptoms is not known. Corticosteroids have been shown to have a wide range of effects on multiple cell types (e.g., mast cells, eosinophils, neutrophils, macrophages, and lymphocytes) and mediators (e.g., histamine, eicosanoids, leukotrienes, and cytokines) involved in inflammation. In 7 trials in adults, FLONASE Nasal Spray has decreased nasal mucosal eosinophils in 66% (35% for placebo) of patients and basophils in 39% (28% for placebo) of patients. The direct relationship of these findings to long-term symptom relief is not known.
physicians center <a href=http://vilinet.communityserver.com/members/Tramadol-Online-569m.aspx>tramadol vs naproxen</a> Nine multicenter, randomized, double-blind, clinical trials comparing cetirizine 5 to 20 mg to placebo in patients 12 years and older with seasonal or perennial allergic rhinitis were conducted in the United States. Five of these showed significant reductions in symptoms of allergic rhinitis, 3 in seasonal allergic rhinitis (1 to 4 weeks in duration) and 2 in perennial allergic rhinitis for up to 8 weeks in duration. Two 4-week multicenter, randomized, double-blind, clinical trials comparing cetirizine 5 to 20 mg to placebo in patients with chronic idiopathic urticaria were also conducted and showed significant improvement in symptoms of chronic idiopathic urticaria. In general, the 10-mg dose was more effective than the 5-mg dose and the 20-mg dose gave no added effect. Some of these trials included pediatric patients aged 12 to 16 years. In addition, four multicenter, randomized, placebo-controlled, double-blind 2–4 week trials in 534 pediatric patients aged 6 to 11 years with seasonal allergic rhinitis were conducted in the United States at doses up to 10 mg.
supplements for fighters <a href=http://vilinet.communityserver.com/members/Phentermine-Online-969m.aspx>extra cheap phentermine diet pills di</a> CeredaseВ® is supplied as a clear sterile non-pyrogenic solution of alglucerase in a citrate buffered solution (53 mM citrate, 143 mM sodium) containing 1% albumin human USP. The enzyme is supplied in one concentration, 400 units per bottle (80 units/mL) with a fill volume of 5 mL per bottle. An enzyme unit (U) is defined as the amount of enzyme required to hydrolyze in one minute one micromole of the synthetic substrate, p-nitrophenyl-Гџ-D-glucopyranoside.
university medicine <a href=http://sharepointmx.mvps.org/members/Tramadol-Online-o69m.aspx>tramadol and diabetic gastroparesis</a> In 103-week oral carcinogenicity studies of lithocholic acid, a metabolite of ursodiol, doses up to 250 mg/kg/day in mice and 500 mg/kg/day in rats did not produce any tumors. In a 78-week rat study, intrarectal instillation of lithocholic acid (1 mg/kg/day) for 13 months did not produce colorectal tumors. A tumor-promoting effect was observed when it was administered after a single intrarectal dose of a known carcinogen N-methyl-N'-nitro-N-nitrosoguanidine. On the other hand, in a 32-week rat study, ursodiol at a daily dose of 240 mg/kg (1,440 mg/m2, 2.6 times the maximum recommended human dose based on body surface area) suppressed the colonic carcinogenic effect of another known carcinogen azoxymethane.
full text <a href=http://www.webjam.com/adipex6l73>adipex 30 mg</a> Treatment with isosorbide dinitrate may be associated with lightheadedness on standing, especially just after rising from a recumbent or seated position. This effect may be more frequent in patients who have also consumed alcohol.
symptoms for anorexia <a href=http://www.jacksonholewy.com/community/members/Adipex-Tablets-No-Prescription.aspx>adipex p no prescription online pharmacy</a> Hattersley A, Bruining J, Shield J, Njølstad P, Donaghue K. International Society for Pediatric and Adolescent Diabetes (ISPAD) Clinical Practice Consensus Guidelines 2006–2007. The diagnosis and management of monogenic diabetes in children. Pediatric Diabetes. 2006;7:352–360.
buy my medicine <a href=http://www.webjam.com/tramadolgl73>tramadol ratiopharm 100 mg</a> "Typical Use" rates mean that the method either was not always used correctly or was not used with every act of sexual intercourse (e.g., sometimes forgot to take a birth control pill as directed and became pregnant), or was used correctly but failed anyway.
24 hr pharmacy <a href=http://blogcastrepository.com/members/Tramadol-Online-q69m.aspx>tramadol cheap that delivers to arkansas</a> Danazol administered orally to pregnant rats from the 6th through the 15th day of gestation at doses up to 250 mg/kg/day (7-15 times the human dose) did not result in drug-induced embryotoxicity or teratogenicity, nor difference in litter size, viability or weight of offspring compared to controls. In rabbits, the administration of danazol on days 6-18 of gestation at doses of 60 mg/kg/day and above (2-4 times the human dose) resulted in inhibition of fetal development.
prednisone generic <a href=http://sharepointmx.mvps.org/members/Phentermine-Online-669m.aspx>phentermine buy withc o d</a> In a clinical pharmacology study of SYMBYAX, three healthy subjects were discontinued from the trial after experiencing severe, but self–limited, hypotension and bradycardia that occurred 2 to 9 hours following a single 12–mg/50–mg dose of SYMBYAX. Reactions consisting of this combination of hypotension and bradycardia (and also accompanied by sinus pause) have been observed in at least three other healthy subjects treated with various formulations of olanzapine (one oral, two intramuscular). In controlled clinical studies, the incidence of patients with a ≥20 bpm decrease in orthostatic pulse concomitantly with a ≥20 mm Hg decrease in orthostatic systolic blood pressure was 0.4% (2/549) in the SYMBYAX group, 0.2% (1/455) in the placebo group, 0.8% (5/659) in the olanzapine group, and 0% (0/241) in the fluoxetine group.
search for symptoms <a href=http://www.wikipatterns.com/users/viewuserprofile.action?username=adipex+consumer+drug+resources>kupie adipex</a> Other: Rare cases of anaphylaxis, bronchospasm, tachycardia, angina (chest pain), hypokalemia, electrocardiographic alterations, vascular occlusive events, and grand mal seizures have been reported. Except for bronchospasm and anaphylaxis, the relationship to ondansetron was unclear.
healthcare pharmacy <a href=http://sharepointmx.mvps.org/members/Phentermine-Online-669m.aspx>online order phentermine site</a> Specific drug interaction studies have not been conducted. Magnesium-containing antacids and HectorolВ® should not be used concomitantly because such use may lead to the development of hypermagnesemia (see <>section-6 WARNINGS]). Although not examined specifically, enzyme inducers (such as glutethimide and phenobarbitol) may affect the 25-hydroxylation of HectorolВ® and may necessitate dosage adjustments. Cytochrome P450 inhibitors (such as ketoconazole and erythromycin) may inhibit the 25-hydroxylation of HectorolВ®. Hence, formation of the active HectorolВ® moiety may be hindered.
medicine online <a href=http://sharepointmx.mvps.org/members/Tramadol-Online-369m.aspx>next day shipping tramadol</a> In patients with severe renal insufficiency, plasma protein binding decreased by 1.0%-1.5% after administration of 60 mg of lansoprazole. Patients with renal insufficiency had a shortened elimination half-life and decreased total AUC (free and bound). The AUC for free lansoprazole in plasma, however, was not related to the degree of renal impairment; and the Cmax and Tmax (time to reach the maximum concentration) were not different than the Cmax and Tmax from subjects with normal renal function. No dosage adjustment is necessary in patients with renal insufficiency.
supplements for muscle <a href=http://www.webjam.com/phentermine_for_patients>how much phentermine can you take</a> Many of the patients who have developed rhabdomyolysis on therapy with simvastatin have had complicated medical histories, including renal insufficiency usually as a consequence of long-standing diabetes mellitus. Such patients merit closer monitoring. Therapy with simvastatin should be temporarily stopped a few days prior to elective major surgery and when any major medical or surgical condition supervenes.
medicine articles <a href=http://szdg.lpds.sztaki.hu/szdg/view_profile.php?userid=34468>90 tramadol 50mg</a> (See <>section-3 BOXED WARNING], <>section-7 CONTRAINDICATIONS], and <>section-8 WARNINGS]). Liver disease impairs the capacity to eliminate valproate. In one study, the clearance of free valproate was decreased by 50% in 7 patients with cirrhosis and by 16% in 4 patients with acute hepatitis, compared with 6 healthy subjects. In that study, the half-life of valproate was increased from 12 to 18 hours. Liver disease is also associated with decreased albumin concentrations and larger unbound fractions (2 to 2.6 fold increase) of valproate. Accordingly, monitoring of total concentrations may be misleading since free concentrations may be substantially elevated in patients with hepatic disease whereas total concentrations may appear to be normal.
symptoms for pain <a href=http://community.midwiferytoday.com/members/Cialis-Free-Consultation.aspx>does cialis work women</a> Enalapril, enalaprilat, and hydrochlorothiazide have been detected in human breast milk. Because of the potential for serious reactions in nursing infants from either drug, a decision should be made whether to discontinue nursing or to discontinue enalapril maleate and hydrochlorothiazide tablets, taking into account the importance of the drug to the mother.
green tea pill <a href=http://vilinet.communityserver.com/members/Phentermine-Online-d69m.aspx>purchase phentermine 24 7</a> In a study in healthy volunteers, coadministration of buspirone (10 mg as a single dose) with grapefruit juice (200 mL double-strength t.i.d. for 2 days) increased plasma buspirone concentrations (4.3-fold increase in Cmax; 9.2-fold increase in AUC). Patients receiving buspirone should be advised to avoid drinking such large amounts of grapefruit juice.
which doctor <a href=http://vilinet.communityserver.com/members/Phentermine-Online-d69m.aspx>pharmacy degree line phentermine online</a> Probenecid: The concomitant use of probenecid with certain other quinolones has been reported to affect renal tubular secretion. The effect of probenecid on the elimination of ofloxacin has not been studied.
medicine faculty <a href=http://forums.autosport.com/index.php?showuser=58907>is phentermine the same as sibutramine</a> From large, well-controlled studies of other nitrates, it is reasonable to believe that the maximal achievable daily duration of anti-anginal effect from isosorbide dinitrate is about 12 hours. No dosing regimen for isosorbide dinitrate, however, has ever actually been shown to achieve this duration of effect. One study of 8 patients, who were administered a pretitrated dose (average 27.5 mg) of immediate-release ISDN at 0800, 1300, and 1800 hours for 2 weeks, revealed that significant anti-anginal effectiveness was discontinuous and totaled about 6 hours in a 24 hour period.
emergency medicine <a href=http://www.design21sdn.com/people/38079>where to buy adipex online</a> Tilt your head back slightly and insert the end of the inhaler into one nostril, pointing it slightly toward the outside nostril wall away from the nasal septum, while holding your other nostril closed with one finger.
island pharmacy <a href=http://blogcastrepository.com/members/Cialis-Online-p69m.aspx>cialis cheap cialis online</a> Table 3 lists treatment-emergent adverse events that occurred in at least 2% of fosphenytoin sodium injection-treated patients in a double-blind, randomized, controlled clinical trial of adult epilepsy patients receiving either IM fosphenytoin sodium injection substituted for oral Dilantin or continuing oral Dilantin. Both treatments were administered for 5 days.
generic downloader.x <a href=http://sharepointmx.mvps.org/members/Phentermine-Online-o69m.aspx>phentermine qt prolongation</a> Olmesartan medoxomil is a drug used to treat high blood pressure (hypertension). It is a type of drug called an angiotensin II receptor blocker. It may be used alone or with other drugs to treat high blood pressure.
dying patients <a href=http://sharepointmx.mvps.org/members/Phentermine-Online-d69m.aspx>no prescription phentermine safe pharmacy</a> Safety of continuous long-term therapy with orphenadrine has not been established. Therefore, if orphenadrine is prescribed for prolonged use, periodic monitoring of blood, urine and liver function values is recommended.
define patients <a href=http://forums.autosport.com/index.php?showuser=58913>tramadol saturday delivery available</a> No specific antidote for lithium poisoning is known. Early symptoms of lithium toxicity can usually be treated by reduction or cessation of dosage of the drug and resumption of the treatment at a lower dose after 24 to 48 hours. In severe cases of lithium poisoning, the first and foremost goal of treatment consists of elimination of this ion from the patient.
drug use <a href=http://blogcastrepository.com/members/Cialis-Online-p69m.aspx>viagra kamagra cialis aneros</a> Obesity happens when a person eats an excess of food relative to the energy they expend. Food is the body's energy source, and, once eaten, it is either stored or used to power the body's metabolism. However, the ways in which factors like appetite, food quality and quantity, energy storage, and energy use interact with each other are complex.
loratadine tablet <a href=http://forums.acdjapan.com/index.php?showuser=3641>tramadol and vicodin interaction</a> People at high risk of death from LQTS are sometimes treated with surgery in which the nerves that prompt the heart to beat faster in response to physical or emotional stress are cut. This helps to keep the heart beating at a steady pace and decreases the chances of developing dangerous heart rhythms in response to stress or exercise.
dentist prescribing <a href=http://blogcastrepository.com/members/Phentermine-Online-s69m.aspx>phentermine chen</a> Women with any of these conditions should be checked often by their health-care provider if they choose to use oral contraceptives. Also, be sure to inform your doctor or health-care provider if you smoke or are on any medications.

Guest on May 03, 2010 |Edit | Edit

Worked for me. could solve the problem in O(1) time.

loop on November 08, 2009 |Edit | Edit

white = 0 black = 1

1. construct a row and a col matrix to record the # of consecutive "1" from current node to left, and up, respectively.

e.g.:

Original (A):
11111
11101
10111
01011

row:
12345
12301
10123
01012

col:
11111
22202
30313
01024

int maxsize = 0;

for i=0; i<N; i++
for j=0; j<N, j++{
if (A[i,j]==1){
for (int k=min(i,j); k>maxsize; k--){ //min(i,j) is the maximum possible square size from i,j to 0,0
if ((row[i,j] - row[i,j-k] == k) &&
(row[i-k,j] - row[i-k,j-k] == k) &&
(col[i,j] - col[i-k,j] == k) &&
(col[i-k,j] - col[i-k,j-k] == k) &&
)
maxsize=k;
break;
}
}
}

still O(n^3) though

khmyzszs on November 09, 2009 |Edit | Edit

<a href="http://khmyzszs.com">yuuyu</a> http://khmyzszs.com [url=http://khmyzszs.com]yuuyu[/url]

khmnhrzs on November 14, 2009 |Edit | Edit

<a href="http://khmnhrzs.com">hgryu</a> http://khmnhrzs.com [url=http://khmnhrzs.com]hgryu[/url]

khmnhrzs on November 17, 2009 |Edit | Edit

<a href="http://khmnhrzs.com">hgryu</a> http://khmnhrzs.com [url=http://khmnhrzs.com]hgryu[/url]

khmnhrzs on November 20, 2009 |Edit | Edit

<a href="http://khmnhrzs.com">hgryu</a> http://khmnhrzs.com [url=http://khmnhrzs.com]hgryu[/url]

Add a Text Comment | Add Runnable Code
Name:
Comment:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.








Amazon (1033)Bloomberg LP (403)Qualcomm (117)Adobe (88)Goldman Sachs (78)NetApp (49)IBM (43)Morgan Stanley (33)CapitalIQ (30)Sophos (25)Achieve Internet (23)Electronic Arts (19)Motorola (18)Research In Motion (17)Flipkart (16)
Microsoft (867)Google (141)NVIDIA (98)Yahoo (82)Epic Systems (69)Expedia (47)VMWare Inc (43)Apple (32)Cisco Systems (28)Facebook (23)Infosys (22)Agilent Technologies (19)Sage Software (17)Deshaw Inc (16)FlexTrade (15)
More Companies »
Software Engineer / Dev... (1062)Financial Software Deve... (170)Testing / Quality Assur... (56)Analyst (35)Virus Researcher (25)Field Sales (15)Developer Program Engin... (9)Front-end Software Engi... (6)MyJoB (5)area sales manager (4)Assistant (3)Cabin crew (2)Accountant (1)personnel (1)Intern (1)
Software Engineer in Te... (288)Program Manager (65)Development Support Eng... (47)INTERN(MSIDC) (28)Web Developer (18)System Administrator (10)Consultant (10)Production Engineer (5)Associate Technology L2 (5)AcquireKnowledge (4)Product Security Engine... (3)Solutions Architect (2)Gamer (1)mts (1)Fresh graduate interview (0)
More Job Titles »
Algorithm (1073)Terminology & Trivia (294)C (166)Object Oriented Design (159)Java (121)Testing (114)Arrays (101)Operating System (78)Database (70)Linked List (62)String Manipulation (56)Networking / Web / Inte... (44)Threads (36)Linux Kernel (33)PHP (22)
Coding (511)C++ (204)Behavioral (159)Data Structures (155)Experience (116)Brain Teasers (111)Computer Architecture &... (79)General Questions and C... (73)Trees and Graphs (69)Math & Computation (57)Application / UI Design (45)Ideas (38)System Design (35)Puzzles (30)Bit Manipulation (20)
More Topics »
CareerCup Official Interview Book Daily Questions Requests for Help Mock Interviews Video for Cracking the Coding Interview Job Placement Service CareerCup Blog
My Profile Edit Profile & Email Settings Sign Out