pedropenduko
BAN USER
@oZZz and @Sunny
I didn't say its 2^n - 1 unique words only, i said that there are 2^n-1 subsets. Check my response below to @Epic_coder.
Thus the number of subsets is N = 2^n - 1.
Then the words count = N! + (N-1)! + (N-2)! + ... + 1
Then less the duplicates FF, EE, II, F, I, E
Total Number of Unique words = words count - 6
You are right we have to consider words whose length is less than 9. Thus this is a subset problem but the different subsets should be 2^n - 1 since an empty set is not considered a valid word.
Thus the number of subsets is N = 2^ - 1.
Then the words count = N! + (N-1)! + (N-2)! + ... + 1
Then less the duplicates FF, EE, II, F, I, E
unique words count = words count - 6
I seem to have misunderstood the question. Why would you consider F & F as distinct alphabets if "FFEICIENT" is valid word based on the problem statement. Also, the 9! didn't consider words whose length is less than 9. Thus, this could be (2^n - 1) as @Epic_coder mentioned. Check http://en.wikipedia.org/wiki/Combination#Number_of_k-combinations_for_all_k
CORRECTION:
2^n -1 subsets not unique words. check my response to @Epic_coder
I believe you did not solve the problem. How are you going to get the count on the last second/minute/hour?
- pedropenduko June 21, 2013Isn't this a simple permutation? So this means it's factorial of length of "EFFICIENT" = 9! = 362880
- pedropenduko June 21, 2013typedef struct _item {
item* next;
void* value;
} item;
void swapKthElem(linkedlist list, int k) {
item* head = list->head;
item* kElemFromHead = NULL;
item* kElemFromTail = NULL;
int i = k;
// scan the list for the kth element from head and kth element from tail
while(head!=NULL) {
if( i-- == 0) {
kElemFromHead = head;
kElemFromTail = list->head;
}
if(kElemFromTail!=NULL) {
kElemFromTail = kElemFromTail->next;
}
head = head->next;
}
// swap only if kth item from head and tail is not the same element
if( kElemFromHead != NULL && kElemFromTail != NULL && kElemFromHead!=kElemFromTail ) {
tmp = kElemFromHead->value;
kElemFromHead->value = kElemFromTail->value;
kElemFromTail->value = tmp;
}
}
Here's a simpler code
function item findElemFromTail(LinkedList list, int k) {
item* p = list->head;
item* elem = NULL;
int i = 0;
while(p!=null) {
if(i == k) {
elem = p;
}
if (item!=null) item = item->next;
p = p->next;
i++;
}
return elem;
}
This is O(N) and we are only scanning the linked list once.
- pedropenduko June 20, 2013Requires two scans to the list there is a better way.
- pedropenduko June 20, 2013function item findElemFromTail(LinkedList list, int k) {
item* p = list->head;
item* elem = NULL;
int k = ;
int i = 0;
while(p!=null) {
if(i == k) {
elem = p;
}
if (item!=null) item = item->next;
p = p->next;
i++;
}
return elem;
}
This is O(N) and we are only scanning the linked list once.
- pedropenduko June 20, 2013Your equalTrees function already uses 2 stack objects. How is this answering the question?
- pedropenduko June 20, 2013I believe you can. If both Binary tree implementation is using an adjacency matrix then you can use iteration to traverse the tree. The matrix is NxN multi-dimensional array. So for a Binary Tree with 10 nodes you get a A[10][10] to represent the relationship of the nodes, all nodes with a value (say non-negative value) represents relationship from source node to target node. You also need an array which contains the values say V[N].
Note that my assumption here is the binary tree has already allocated the arrays as a representation of the trees and it node values. The problem we are trying to solve is if our comparison require additional space, and my answer is we don't need additional space as long as its represented this way as a tree. Of course you need the iteration variables.
So for example if you have an entry A[1][2] = 1 and A[1][3] = 1 then Node 1 has two children Node 2 and Node 3. Then lookup the values array say V[1], V[2] and V[3] for the values. Just compare these indexes on both the binary trees. If at least one is not equal then exit your iteration and the trees are not equal.
How are the counters reset if there are no request coming in for that specific second (assuming previously that specific second has a value but the counter value was 1 hour old)? This means there is a possibility that the counter values are incorrect depending on the timing of the requests coming in.
- pedropenduko June 20, 2013A self referential table would work.
1
/ \
2 3
/ \ \
4 5 6
Example Node Table
| ItemId | ParentId |
| 1 | NULL |
| 2 | 1 |
| 3 | 1 |
| 4 | 2 |
| 5 | 2 |
| 6 | 3 |
To select parent of node 2:
SELECT ParentId FROM Node WHERE ItemId = 2;
To select children of node 2:
SELECT ItemId FROM Node Where ParentId = 2;
Isn't it simpler to just store the timestamps of all requests from current time - hour up to current time in a queue?
You can create the a queue which contains all the timestamps as requests come in.
Then every time interval say every 1millisecond remove all the timestamps in the head which is 1 hour old.
All you have to do to get the count is is peek from the head of the queue up to last the time stamp which is current queue timestamp > current time - hour/minute/seconds.
Or alternatively just create a score array say int score[3] and update every millisecond by reading the queue as described above and update the counters.
RepArnavPatel, abc at A9
Dedicated and energetic bakery assistant with a passion for flavor and a love for creating. Professional and dependable with more ...
Repkristinelavo, HR Executive freshers at Automated Traders Desk
Kristine , a Content Strategist who excels at developing and implementing social media plans, creating original online content, managing websites and ...
RepNoahTaylor, abc at A9
Accomplished software developer with many years of experience in development of applications. Excels in every stage of the life cycle ...
Repjasmineouzts765, Apple Phone Number available 24/7 for our Customers at 247quickbookshelp
JasmineOuzts and I am a web designer and freelance fashion blogger. I love writing about the latest trends in the ...
RepRutviLopez, abc at A9
I have demonstrated skills in written communication with multiple award winning pieces and a strong willingness to revise and edit ...
RepElkeRoll, Animator at A9
I am Elke from the USA. I am working as a technologist in Hill-Behan company. I perform and analyze the ...
Repnovathomes, abc at 8x8
I am a friendly and outgoing person who enjoys greeting people with a smile. I have more than eight years ...
RepTaylahMacge, Consultant at Accenture
Assigned to manage the requirements of foreign clients specifically those from the Chinese, Arabic, and French-speaking markets.I am passionate ...
Repmandybourne5463, Accountant at ABC TECH SUPPORT
MandyBourne, and I am a Computer typesetter and I love my work. Apart from this, today I am doing new ...
Replillianrperkins66, Android test engineer at ABC TECH SUPPORT
I'm Lillian Perkins, and I'm a studio camera operator. A studio camera operator Main work includes operating cranes ...
Reppennyruddie, Cloud Support Associate at Accenture
Training Coordinator focuses on transaction quality, efficiency, and facility management. develops effective training for the programme “ mantra for attract girl ...
RepLopezKape, Applications Developer at A9
Lopez , an Outgoing Headhunter with a comprehensive background of client satisfaction in finding and recruiting top talent for various organizations ...
Reprommie93544, Field Sales at Citrix Online
Roomie , an experienced group fitness instructor with the drive and knowledge and enthusiasm to apply the correct fitness techniques to ...
Repirenereed98, Discount Furniture Showcase at Physical therapist aid
I'm a Physical advisor helping working at Discount Furniture Showcase . I'm likewise a film buff who partakes in ...
Repreiviasmith, Malwarebytes customer service at ABC TECH SUPPORT
I am Reivia an outgoing and motivated Travel Consultant with over 5 years of experience in delivering professional travel related ...
Reprudystake, Game Programmer at BrowserStack
I am Rudy , a physical therapist with extensive knowledge of sports injuries and therapy . Strong background in athletic coaching and ...
Reprajanadeep17, Android Engineer at 247quickbookshelp
I am a Special education teacher who adapts general education lessons and teaches various subjects to students with mild to ...
RepMoniKim, Animator at Clean Power Research
I am Moni , a reliable Special Projects/Order Filler people oriented personality with great organizational and interpersonal communication skills. I ...
RepNirvedDavis, abc at 8x8
Professional lifeguard offering expertise in water safety. Worked for more than six years in guarding and controlling the safety of ...
RepAadavThomas, abc at A9
I am a well skilled and innovative Industrial Designer who focuses on taking products, noting product ideas and making them ...
Repdanikademers, HTML Experienced at Barclays Capital
I am Danika , working as a junior content writer with Jafco where I use my blog writing and social media ...
Rephugaliuli, Nurse at 8x8
Registered nurse with experience in delivering quality care to patients. Professional with more than 3 years in emergency room care ...
Reptabithalaws245, Computer Scientist at Absolute Softech Ltd
I am a Quality auditor Friendly technicians with over six years experience solving customer technical issues quickly and effectively. and ...
Repkany7635, optician at AMMB
I am a detail oriented and knowledgeable optical assistant with 2 years of experience in an optometry office setting. Collect ...
Repnetteyoder22, Applications Developer at 247quickbookshelp
Nette, transportation inspector inspects goods and equipment associated with transporting people or cargo to ensure safety. I typically work for ...
RepAadavKiva, abc at 8x8
By profession I am a blogger and passionate about writing new and informative blog content who easily understand visitors. Nowaday ...
RepJohnPitts, Development Support Engineer at Barclays Capital
John , an urban regional planner with over four years of experience helping cities and local areas to properly plan for ...
Repbenaryhell3454, Blockchain Developer at A9
Working as a carpet installer at Simple Solutions is almost 10 years . Here I daily meet new people and learn ...
RepFurryReign, Questions - Problem Solving Round at Cerberus Capital
Furry , An Athletic Trainer with confidence that my 7 years of experience in various organizations and industries have given me ...
Repjacquelinejlopes48, Analyst at 247quickbookshelp
Hey, I am Jacqueline and I am a court reporter.I had heard a lot about Vashikaran Specialist,now I ...
Repbungayasorya, Accountant at BrowserStack
An archeologist is an expert on history who gains expertise through experience with historical documents and artifacts. The archaeological record ...
RepNoraMiller, abc at A9
Confident and dedicated photographer with experience in both professional and freelance photography.. Prioritizes communication on the job to avoid errors ...
RepManbirTaylor, abc at 247quickbookshelp
I have strong communication skills that have been developed over a customer service career of nearly 3 years. I have ...
RepAlvaPolly, Animator at ADP
I am Alva , working as a Brand Specialist with two years experience in Keeney's. I’ve excellent communication and ...
Repzippy28943, Data Scientist at AppNexus
Maxine , a grant writer specializing in researching and analysing grant opportunities, creating funding plans, and conducting proposals and budgets. Last ...
RepAngelaFox, Android Engineer at AMD
My name is AngelaFox . I'm working at Integra Design as a Municipal court judge . The adjudicator acts in the ...
Very simple and clear solution. Get the root and do a DFS using adjacency list as tree data structure.
- pedropenduko January 16, 2014