US coin values:
.01, .05, .10, .25 (*)
What configuration(s) of US coins can be used to match every value from .01-.99 using the fewest coins possible?
How can you find an answer?
* note: there is actually a .50 coin but it is very rarely seen
Hello Friends,
Actually I am working on Pdf by using IReport Software. This software provided two detail section but i want this two detail section with Column Header .then say me how i changes it
reply me on [email protected]
Recently I was asked to express the DI in colloquial explanation.
I answered :
1)
I am going to a hotel.I ordered food.The hotel management asks me to clean the plates and
clean the tables.So here i am a client,I am responsible for managing the service (Instantiating,executing,disposing).But DI decouples such tasks so the service consumer no need not worry about controlling the life cycle of the service.
2)
He also asked is there any microsoft API follows DI ?.I answered (This was my guess) In WCF you can create a Proxy using ChannelFactory that controls the life time of your factory.
for item (1) he said only 10% is correct
for item(2) he said that is factory pattern not dependency injection.
Actually what went wrong in my explanation (apart from my bad English) ? What is the real answers for those?
I am waiting for your valuable suggestions.
Consider the following class definition:
class StrToTokens {
StrToTokens(const char* str, const char* delimiters = "\t\r\n"); //constructor
string getNextToken();
void reset();
bool empty();
}
Can someone list some good testcases to test the above class.
A few I could think of are:
empty string, empty delimiters, repeated delimiters, consecutive delimiters, string with only delimiters.
However, the interviewer expected some more(better ones). Can you help out.
Thanks.
I would like the SO community let me know what does juniors and proficient .NET Developers should know regarding the following subjects, also some code examples or brainteasers like the ones here will help a lot.
System Types
Collection and Generics
Configuration and Installation
Monitoring and Debugging
File I/O
Globalization
How can i do subtraction of integers in C without using either the unary or binary '-' operator?
Or can we do the same for other data types like float/double?
I have recently come across an interesting question on strings. Suppose you are given following:
Input string1: "this is a test string"
Input string2: "tist"
Output string: "t stri"
So, given above, how can I approach towards finding smallest substring of string1 that contains all the characters from string 2?
Hello,
I want to improve my chances getting a job (entry-level:programming) by learning another language.
How many jobs that require exclusively French, German, English are there ?
Which is better to learn (more/better jobs): French or German ?
Is it worth it (or should I learn another programming language instead :D) ?
Thank you.
P.S I live in Romania, I (think I) know English
I came across this question: say given two weights 1 and 3, u can weigh 1,2 (by 3-1),3,4 (by 3+1). Now find the minimum number of weights so that you can measure 1 to 1000.
So the answer was 1,3,9,27...
I want to know how do you arrive at such a solution means powers of 3. What is the thought process?
Source: http://classic-puzzles.blogspot.com/search/label/Google%20Interview%20Puzzles
Solution: http://classic-puzzles.blogspot.com/2006/12/solution-to-shopkeeper-problem.html
You are going on a one-way indirect flight trip that includes billions transfers. You are not stopping twice in the same airport. You have 1 ticket for each part of your trip. Each ticket contains src and dst airport. All the tickets you have are randomly sorted. You forgot the original departure airport (very first src) and your destination (last dst).
Design an algorithm to reconstruct your trip with minimum big-O complexity.
Hi,
I could not find an errata for the 2nd edition of this book. My question concerns the if-statement in the following piece of code.
void removeHead (Node ** head) {
Node * temp;
if (!(*head)) {
temp = (*head)->next;
delete *head;
*head = temp;
}
}
So I understand that the point of the if-statement is to check if the Node is null. However by adding an additional "!" to the evaluation, wouldn't this negate the false value of null? Would it be correct to change it to something like:
if (*head) { ... }
Also if anyone knows where I can find an official errata for the 2nd edition that would be great.
Thanks,
Sam
Possible Duplicate:
Algorithm to find a duplicate entry in constant space and O(n) time
Given an array of N integer such that only one integer is repeated. Find the repeated integer in O(n) time and constant space. There is no range for the value of integers or the value of N
For example given an array of 6 integers as 23 45 67 87 23 47. The answer is 23 (I hope this covers ambiguous and vague part)
I searched on the net but was unable to find any such question in which range of integers was not fixed. Also here is an example that answers a similar question to mine but here he created a hash table with the highest integer value in C++.But the cpp does not allow such to create an array with 2^64 element(on a 64-bit computer).
Hello
I am working on a proposal where we have to implement a software which can move files between one source to destination.The overall goal of this project is to create intelligent file transfer.This software will have three components :-
1) Broker : Broker is the module that communicates with other brokers, monitors files, moves files, retrieves configurations from the Configuration Manager, supplies process information for the monitor, archives files, writes all process data to log files and escalates issues if necessary
2) Configuration Manager :Configuration Manager is a web-based application used to configure and deploy the configuration to all brokers.
3) Monitor : Monitor is a web-based application used to monitor each Broker in the environment.
This project has to be built up in java and protocol for file transfer in tcp/ip. Client does not want to use FTP.
File Transfer seems very easy, until there are several processes who are waiting to pick the file up automatically. Several problems arise:
How can we guarantee the file is received at the destination?
If a file isn’t received the first time, we should try it again (even after a restart or power breakdown) ?
How does the receiver knows the file that is received is complete?
How can we transfer multiple files synchronously?
How can we protect the bandwidth, so file transfer isn’t blocking other processes?
How does one interoperate between multiple OS platforms?
What about authentication?
How can we monitor het workflow?
Auditing / logging
Archiving
Can you please provide answer to some of these?
Thanks
I don't even know if a solution exists or not. Here is the problem in detail. You are a program that is accepting an infinitely long stream of characters (for simplicity you can assume characters are either 1 or 0). At any point, I can stop the stream (let's say after N characters were passed through) and ask you if the string received so far is a palindrome or not. How can you do this using less sub-linear space and/or time.
US coin values:
.01, .05, .10, .25 (*)
What is an algorithm to determine what configuration(s) of US coins can be used to match every value from .01-.99 using the fewest coins possible?
* note: there is actually a .50 coin but it is very rarely seen
I recently came in contact with this interesting problem. You are given a string containing just the characters '(', ')', '{', '}', '[' and ']', for example, "[{()}]", you need to write a function which will check validity of such an input string, function may be like this:
bool isValid(char* s);
these brackets have to close in the correct order, for example "()" and "()[]{}" are all valid but "(]", "([)]" and "{{{{" are not!
I came out with following O(n) time and O(n) space complexity solution, which works fine:
Maintain a stack of characters.
Whenever you find opening braces '(', '{' OR '[' push it on the stack.
Whenever you find closing braces ')', '}' OR ']' , check if top of stack is corresponding opening bracket, if yes, then pop the stack, else break the loop and return false.
Repeat steps 2 - 3 until end of the string.
This works, but can we optimize it for space, may be constant extra space, I understand that time complexity cannot be less than O(n) as we have to look at every character.
So my question is can we solve this problem in O(1) space?
This question was mentioned here.
My doubt is: If a pointer variable has the same address as its value, is it really pointing to itself?
For example - in the following piece of code, is a a pointer to itself?
#include<stdio.h>
int main(){
int* a;
int b = (int)&a;
a = b;
printf("address of a = %d\n", &a);
printf(" value of a = %d\n", a);
}
If a is not a pointer to itself, then the same question poses again: Can a pointer point to itself?
Also, how is a self pointing pointer useful?
I saw this question in one of the C puzzles!!
Is this really possible?
How can I call a function, given its name as a string?
is it possible to use string that is read with scanf be used directly to call
a function?
i already have thought of if(strcmp(str,"string"))then call the function.
but is there any other approach?