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"
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.
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).