1. read the file one char at a time, and tokenize the standalone words (stop
char is either space or comma or eol)
2. put each parsed word in a structure "map<char, vector<string> >", where
the char is the key (the first letter of each scanned word). You are
basically creating a hash table here.
3. now print the hash table content using the formatting of your choice.

Rgds,
Ashot

-----Original Message-----
From: [email protected] [mailto:[email protected]] On
Behalf Of Gobind Kumar Hembram
Sent: Friday, June 22, 2012 2:01 PM
To: [email protected]
Subject: [algogeeks] Programming Question

I was asked this question in one company Programming Round.Please help
me in solving this,I tried with array of pointers ,2-D array and by
buffering.

You have a file with names of brands separated by comma. Write a
program (in language of your choice) to group them by their starting letter.

For example, if the input file is this:
Reebok, Puma, Adidas, Clarks, Catwalk, Converse, FILA, Lotto, Newfeel,
Nike, Numero Uno, New Balance, ASICS, Carlton London, Crocs

The program should print the following:
A
 ASICS, Adidas

C
 Carlton London, Catwalk, Clarks, Converse, Crocs

F
 FILA

L
 Lotto

N
 New Balance, Newfeel, Nike, Numero Uno

P
 Puma

R
 Reebok

-- 
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to