Programming questions/puzzles

Jul 15, 2010 at 9:42pm
Hi,

I am trying to build up a better logical approach to solving problems in C++. Hence i am looking for some questions which would qualify for "Homework" or "Interview" Questions flagship. Examples of such questions include.

- Remove an element in Array/Vector (delete it)
- Sort an array.
- Remove duplicates from array.
- Reverse a string/recursively.
- Traverse a tree/list.
- Find highest sum in the sequence of array elements {1,2,-1,-5,4,6} i.e range indexes.

I.e in short problems which are easy to solve , yet have optimized solutions.

If some one has a book which presents such brainteasers , please let me know. All links are welcome as well.. I lack Googling skills so more or less i end up with the usual "Why copy constructor"

Cheers!
Last edited on Jul 15, 2010 at 9:43pm
Jul 15, 2010 at 9:45pm
Ask the user to enter an amount of money less than $10.00.
Using only $5 bills, $1 bills, quarters, nickels, dimes, and pennies,
output all the possible ways you could make that amount of money.

EDIT: Or, just output the number of ways you could make that amount of money.
Last edited on Jul 15, 2010 at 9:46pm
Jul 15, 2010 at 11:29pm
For people who just want to get the job done without studying the STL in depth, there is this book: C++ Cookbook from O'Reilly
Jul 16, 2010 at 12:16pm
Thanks guys! Exactly what i was looking for

Cheers!
Jul 16, 2010 at 12:52pm
closed account (oz10RXSz)
1. Find a number of all fours (a,b,c,d) such that (a + b + c = d), where a, b, c, d are integers from the given set. Do it in O(n^2).

2. Display all the words that can be created from 7 given letters (as in Scrabble). The dictionary is given in a file, one word per line. Do the search in O(const).

Last edited on Jul 16, 2010 at 12:54pm
Topic archived. No new replies allowed.