跳至主要内容

博文

Square root of a number (sqrt)

For many technical interviews in big companies, one question might be asked frequently, which is how to compute a number's square root. Based on my experience, Yahoo and Linkedin interviewers like it in the first phone screen.  It looks so simple that many people would neglect some nature behind its appearance. In my blog, I will focus on the analysis part and spend some time on testing because I believe that people can not give perfect coding solution without solid analysis and sound testing cases. Let's get into it. Problem description Given you a number, compute its square root. Analysis 1) Before we start, we have to truly and totally understand what the meaning of the problem is. More importantly, in the interview process, we should know what method or technology the interviewers want us to show to them. So ask them conditions in the problem to clear ambiguities. In this case, what kind of number is as the input, integer or float? Is it a perfect square root problem?
最新博文

WEEKLY ADDRESS: Calling for Limited Military Action in Syria

Remarks of President Barack Obama Weekly Address The White House September 7, 2013 Video Almost three weeks ago in Syria, more than 1,000 innocent people – including hundreds of children – were murdered in the worst chemical weapons attack of the 21 st  century.  And the United States has presented a powerful case to the world that the Syrian government was responsible for this horrific attack on its own people. This was not only a direct attack on human dignity; it is a serious threat to our national security.  There’s a reason governments representing 98 percent of the world’s people have agreed to ban the use of chemical weapons.  Not only because they cause death and destruction in the most indiscriminate and inhumane way possible – but because they can also fall into the hands of terrorist groups who wish to do us harm. That’s why, last weekend, I announced that, as Commander in Chief, I decided that the United States should take military action against the Syrian

WEEKLY ADDRESS: Pursuing a Diplomatic Solution in Syria

Remarks of President Barack Obama Weekly Address The White House September 14, 2013 Video This week, when I addressed the nation on Syria, I said that – in part because of the credible threat of U.S. military force – there is the possibility of a diplomatic solution.  Russia has indicated a new willingness to join with the international community in pushing Syria to give up its chemical weapons, which the Assad regime used in an attack that killed more than 1,000 people on August 21.  I also asked Congress to postpone a vote on the use of military force while we pursue this diplomatic path.  And that’s what we’re doing.    At my direction, Secretary of State Kerry is in discussions with his Russian counterpart.  But we’re making it clear that this can’t be a stalling tactic.  Any agreement needs to verify that the Assad regime and Russia are keeping their commitments: that means working to turn Syria’s chemical weapons over to international control and ultimately destro

WEEKLY ADDRESS: Congress Must Act Now to Pass a Budget and Raise the Debt Ceiling

Remarks of President Barack Obama Weekly Address The White House September 21, 2013 Video Hi, everybody.  It was five years ago this week that a financial crisis on Wall Street spread to Main Street, and very nearly turned a recession into a depression.  In a matter of months, millions of Americans were robbed of their jobs, their homes, their savings – after a decade in which they’d already been working harder and harder to just get by.  It was a crisis from which we’re still trying to recover.  But thanks to the grit and determination of the American people, we are steadily recovering.  Over the past three and a half years, our businesses have created seven and a half million new jobs. Our housing market is healing. We’ve become less dependent on foreign oil.  Health care costs are growing at the slowest rate in 50 years.  And in just over a week, millions of Americans without health care will be able to get covered for less than $100 a month.  So our economy is ga

WEEKLY ADDRESS: Making Higher Education More Affordable for the Middle Class

Remarks of President Barack Obama Weekly Address The White House August 24, 2013 Video Hi, everybody.  Over the past month, I’ve been visiting towns across America, talking about what our country needs to do to secure a better bargain for the middle class.  This week, I met with high school and college students in New York and Pennsylvania to discuss the surest path to the middle class – some form of higher education. But at a moment when a higher education has never been more important, it’s also never been more expensive.  That’s why, over the past four years, we’ve helped make college more affordable for millions of students and families with grants and loans that go farther from before. But students and families and taxpayers cannot just keep subsidizing college costs that keep going up and up.  Not when the average student now graduates more than $26,000 in debt. We cannot price the middle class out of a college education.  That’s why I proposed major new reforms

WEEKLY ADDRESS: Let’s Get Back to the Work of the American People

Remarks   of   President   Barack   Obama   Weekly   Address The   White   House October  12, 2013 video Good   morning . Over   the   past   few   days ,  I ’ ve   met   with   Republicans   and   Democrats   from   both   houses   of   Congress  in   an   effort   to   reopen   your   government   and   remove   the   dangers   of   default   from   our   economy . It ’ s   a   positive   development   that   House   Republicans   have   agreed   on   the   need   to   avoid   the  economic   consequences   of   not   meeting   our   country ’ s   commitments .  Because   once   the   debt   ceiling  is   raised ,  and   the   shutdown   is   over ,  there ’ s   a   lot   we   can   accomplish   together . We ’ ve   created   seven   and   a   half   million   new   jobs   in   the   past   three   and   a   half   years .  Now   let ’ s   create  more .  We ’ ve   cut   our   deficits   in   half   over   the   past   four   years .  Now   let ’ s   do   it   in   a   sm

WEEKLY ADDRESS: Averting a Government Shutdown and Expanding Access to Affordable Healthcare

Remarks   of   President   Barack   Obama   Weekly   Address The   White   House September  28, 2013 video Hi, everybody.  This Tuesday is an important day for families, businesses, and our economy.  It’s the day a big part of the Affordable Care Act kicks in, and tens of millions of Americans will finally have the same chance to buy quality, affordable health care as everyone else. It’s also the day that a group of far-right Republicans in Congress might choose to shut down the government and potentially damage the economy just because they don’t like this law. I’ll get to that in a second.  But first – here’s what the Affordable Care Act means for you. If you’re one of the vast majority of Americans who already have health care, you already have new benefits you didn’t before, like free mammograms and contraceptive care with no copay, and discounts on prescription medicine for seniors.  You’ve already got new protections in place too, like no more lifetime limits on your