AlaaShaker's Weblog

// untitled …

Posts Tagged ‘Problems

Alphabetic Phone Number Generator [Problem of the Week]

with 15 comments

Mmm, not quite problem of the “week” since it has been a while since I last posted a problem – I had a busy few weeks, my apologies!

Anyway, let’s move to the problem – another Microsoft interview problem. Sure you’ve all seen how phone pads hold three letters of the alphabet for every number you can press (except for 1 and 0). Check the photo below to know what I mean …

Phone Pad

The problem is simple. The input is a distinct, seven-digit number. The required output is all seven-character strings that could be generated from this number. Read the rest of this entry »

Written by AlaaShaker

October 3, 2008 at 12:12 am

Count Open Lockers [Problem of the Week]

with 15 comments

Last week’s problem was a mistake – I had to suffer LOTS of code tracing and compiling. I had a troublesome “code” week here and in work ..
Anyway, as a result, no coding this week – just pure brain-work!

This week’s problem is a brainteaser, also is asked in interviews. The main point behind it is to show your interviewer how you could think to solve difficult, vague problems. Here’s the problem ..

Lockers

Suppose you are in a hallway lined with 100 closed lockers. You begin by opening all 100 lockers. Next, you close every second locker. Then you go to every third locker and close it if it is open or open it if it is closed (call this toggling the locker). You continue toggling every nth locker on pass number n. After your hundredth pass of the hallway, in which you toggle only locker number 100, how many lockers are open?

In a hall with k lockers, how many lockers remain open after pass k?

I’m sure I’ll get tons of questions about that, so here’s a second explanation: Imagine this hallway of 100 lockers. You make “passes” on these lockers .. Read the rest of this entry »

Written by AlaaShaker

September 1, 2008 at 2:37 pm

Link-the-Tree [Problem of the Week]

with 35 comments

Seems that last week’s problem was a bit difficult as Fouad stated in his last problem, so this weeks it’s an easier one .. not that easy though. It should be easy for all ACMers .. we’ll see!
I first met this problem in a physical Microsoft technical interview (and solved it a7l), which stresses how being an ACMer helped me a lot in passing interviews. Actually, that Microsoft interview is broken into four interviews: three in problem solving (= ACM) and one in System Architecture, Analysis and Design.

Anyway, here’s how this problem goes ..

Incomplete Binary Tree

You have a binary tree, not necessarily complete, where each Node holds two pointers (left and right) and a character as an identifier. Read the rest of this entry »

Written by AlaaShaker

August 24, 2008 at 4:08 pm

Secret Creator [Problem of the Week]

with 29 comments

After the Design Patterns course has ended in FCIS, and following up with the wicked problems of my friend, Fouad, I decided to post a code design problem I heard lately …

class Secret
{
    // TODO: class body goes here ..
}
class Creator
{
    // TODO: class body goes here ..
}

You have two classes: Secret and Creator.

Code both classes such that no other class than Creator is allowed to instantiate a local object of Secret. In other words, I can create an object of Secret as long as this code is inside Creator. If I’m inside any other class than Creator, I can’t!!! Read the rest of this entry »

Written by AlaaShaker

August 16, 2008 at 5:05 pm

Google Treasure Hunt

without comments

Last week, Google Australia has launched Google Treasure Hunt 2008, a problem-solving contest  in computer science fields, posting a problem per week.

GoogleTreasureHunt2008

The Google Engineering team is launching its first ever Treasure Hunt – a contest designed to challenge your problem-solving skills. Starting soon, we’ll be releasing the first of four puzzles, drawing from computer science, networking, and low-level UNIX trivia. Each puzzle will be posted online week by week, and the first entrants to submit correct answers to each question will receive a prize.

I gave it a shot with the first problem – it wasn’t as bad as I expected!
It just had a small trick. I’ll leave figuring that out to you ..

Written by AlaaShaker

May 18, 2008 at 11:55 pm

Posted in Technology

Tagged with ,