-
ProgrammingInterview commented 6 days ago
Thanks for the good explanation! I was about to say without code and console output I really cannot help much. Now you saved us! Thanks man
This item has been hiddenIn the future you will only see uploads from ProgrammingInterviewIn the future you will see all activity from ProgrammingInterviewYou have been unsubscribed from ProgrammingInterview -
ProgrammingInterview commented 1 week ago
Oh, thanks for the good catch. Will fix that soon.
This item has been hiddenIn the future you will only see uploads from ProgrammingInterviewIn the future you will see all activity from ProgrammingInterviewYou have been unsubscribed from ProgrammingInterview -
ProgrammingInterview commented 1 week ago
Cool. Thank you. Could you please provide any link of your code? Or you may create a video response to mine? Thanks again.
This item has been hiddenIn the future you will only see uploads from ProgrammingInterviewIn the future you will see all activity from ProgrammingInterviewYou have been unsubscribed from ProgrammingInterview -
ProgrammingInterview commented 1 week ago
Very good point! Your solution is easier to understand and more efficient in memory use. If you'd like to provide your code, that will be super awesome. Thanks a lot.
This item has been hiddenIn the future you will only see uploads from ProgrammingInterviewIn the future you will see all activity from ProgrammingInterviewYou have been unsubscribed from ProgrammingInterview -
ProgrammingInterview commented 1 week ago
Good point! This simplifies the code. Will fix that soon. Thanks.
This item has been hiddenIn the future you will only see uploads from ProgrammingInterviewIn the future you will see all activity from ProgrammingInterviewYou have been unsubscribed from ProgrammingInterview -
ProgrammingInterview commented 1 week ago
All my code can be downloaded at goo.gl(slash)fAhQ9
This item has been hiddenIn the future you will only see uploads from ProgrammingInterviewIn the future you will see all activity from ProgrammingInterviewYou have been unsubscribed from ProgrammingInterview -
ProgrammingInterview commented 1 week ago
Basically this problem is exponentially expensive as the money value increases because I need "print all possible combinations" other than to compute the number of ways of getting the particular amount. I am not sure about the missing case. Could you please provide the missing case for 25cents s...
This item has been hiddenIn the future you will only see uploads from ProgrammingInterviewIn the future you will see all activity from ProgrammingInterviewYou have been unsubscribed from ProgrammingInterview -
ProgrammingInterview commented 1 week ago
Thanks for the comment. Duplicated are allowed. We are justing sorting it using the quicksort idea and we stop when we identify the value which is in kth position after splitting. Hope this answers your question.
This item has been hiddenIn the future you will only see uploads from ProgrammingInterviewIn the future you will see all activity from ProgrammingInterviewYou have been unsubscribed from ProgrammingInterview -
ProgrammingInterview commented 3 weeks ago
Hey I did test my code and it's working for your case. Maybe try to download the code from the code portal other than type it down from the video? Let me know if that works. Thanks,
This item has been hiddenIn the future you will only see uploads from ProgrammingInterviewIn the future you will see all activity from ProgrammingInterviewYou have been unsubscribed from ProgrammingInterview -
ProgrammingInterview commented 3 weeks ago
The challenge is you also need to make sure this is a palindrome string, but I do get your point of using duplicate-substring method. Thanks.
This item has been hiddenIn the future you will only see uploads from ProgrammingInterviewIn the future you will see all activity from ProgrammingInterviewYou have been unsubscribed from ProgrammingInterview -
ProgrammingInterview commented 3 weeks ago
That's right! Good catch. I have tried in the downloadable code to fix this issue. Thanks again.
This item has been hiddenIn the future you will only see uploads from ProgrammingInterviewIn the future you will see all activity from ProgrammingInterviewYou have been unsubscribed from ProgrammingInterview -
ProgrammingInterview commented 3 weeks ago
Cool, how's your interview going? Wish you good luck! That's good you give me the keyword to search for, I guess anybody watching this video and paying attention to the comment will try to look for it themselves. Thanks.
This item has been hiddenIn the future you will only see uploads from ProgrammingInterviewIn the future you will see all activity from ProgrammingInterviewYou have been unsubscribed from ProgrammingInterview -
ProgrammingInterview commented 1 month ago
Thanks. I agree using this "how many rotations" is unclear and misleading. Probably using the phrase "number of index rotation" could be better. But anyway, sometime interviewers gave very vague problem statement, the process to make sure of the question itself can be a way to evaluate an intervi...
This item has been hiddenIn the future you will only see uploads from ProgrammingInterviewIn the future you will see all activity from ProgrammingInterviewYou have been unsubscribed from ProgrammingInterview -
ProgrammingInterview commented 1 month ago
Thanks to Gang Yao, I fixed one bug. When initially setting previous pointer, it should not be set as null, because in case of root node has no right child the code stops immediately. As suggested by Gang, I set the previous pointer as an arbitrary dummy tree node, so it will resolve the mentione...
This item has been hiddenIn the future you will only see uploads from ProgrammingInterviewIn the future you will see all activity from ProgrammingInterviewYou have been unsubscribed from ProgrammingInterview -
ProgrammingInterview commented 1 month ago
Sorry my bad. I have fixed that in the download code. Thanks for the good catch~
This item has been hiddenIn the future you will only see uploads from ProgrammingInterviewIn the future you will see all activity from ProgrammingInterviewYou have been unsubscribed from ProgrammingInterview -
ProgrammingInterview commented 1 month ago
I envy you guys good math abilities. Oh I should have mentioned that I PERSONALLY ASSUME order does not matter, sorry I implicitly assume people will think so haha. Thanks for pointing this out. I will change the title by adding "regardless of order of coins"
This item has been hiddenIn the future you will only see uploads from ProgrammingInterviewIn the future you will see all activity from ProgrammingInterviewYou have been unsubscribed from ProgrammingInterview -
ProgrammingInterview commented 1 month ago
Thanks. Good question. Actually I assumed the values are unique, bad assumption.
Obviously for cases that duplicates values exist in binary trees, there can be multiple binary trees constructed, for example PreOrder{1,1,1} and InOrder{1,1,1}.
I guess this is not easy to fix and I personally thi...
This item has been hiddenIn the future you will only see uploads from ProgrammingInterviewIn the future you will see all activity from ProgrammingInterviewYou have been unsubscribed from ProgrammingInterview -
ProgrammingInterview commented 1 month ago
Thanks, actually I didn't understand NP hard. I wiki it just now haha. Thanks for your explanation now I understand this a little better.
In my way of understanding, you want to tell me this problem can be too complex regarding time even the input size is small. I completely agree with you. I ju...
This item has been hiddenIn the future you will only see uploads from ProgrammingInterviewIn the future you will see all activity from ProgrammingInterviewYou have been unsubscribed from ProgrammingInterview -
ProgrammingInterview commented 1 month ago
That's a good catch. I initially thought it's useful but later found this is useless. But can be no harm left here, in case next time we are interviewed with the Smallest Contiguous Subsequent Product :P
This item has been hiddenIn the future you will only see uploads from ProgrammingInterviewIn the future you will see all activity from ProgrammingInterviewYou have been unsubscribed from ProgrammingInterview -
ProgrammingInterview commented 1 month ago
I guess you are from data-mining background, but I'm not. So I try my best to give you my answer. Firstly, even the complexity can be unbelievable huge, the problem is clear that is to get ALL possible combination of coins for a given amount. So even as huge as your given amount, still we just pr...
This item has been hiddenIn the future you will only see uploads from ProgrammingInterviewIn the future you will see all activity from ProgrammingInterviewYou have been unsubscribed from ProgrammingInterview -
ProgrammingInterview commented 1 month ago
Logically utubpastor's solution should work and it's the best code interviewers want to see I guess. H1A2R3S4H5, you may want to double check your code implementation. Sometime the index settings may ruin your plan.
This item has been hiddenIn the future you will only see uploads from ProgrammingInterviewIn the future you will see all activity from ProgrammingInterviewYou have been unsubscribed from ProgrammingInterview -
ProgrammingInterview commented 1 month ago
I am afraid this won't work correctly. As you notice my code to check the row/column/box may be a bit awkward but they highly depend on the numbers set on the board. So I want to clean all the data that are set after this particular position I am currently focusing on. So I assume if we simply th...
This item has been hiddenIn the future you will only see uploads from ProgrammingInterviewIn the future you will see all activity from ProgrammingInterviewYou have been unsubscribed from ProgrammingInterview -
ProgrammingInterview commented 1 month ago
Actually I thought over this case when I prepare this video, I think this should not be set. Think about the case {-0.5, 100, -4} or {-0.5, -100, 1}. We need keep the -0.5 though it's absolute value is less than 1.
This item has been hiddenIn the future you will only see uploads from ProgrammingInterviewIn the future you will see all activity from ProgrammingInterviewYou have been unsubscribed from ProgrammingInterview -
ProgrammingInterview commented 1 month ago
Good point! Forgive my bad coding style.
This item has been hiddenIn the future you will only see uploads from ProgrammingInterviewIn the future you will see all activity from ProgrammingInterviewYou have been unsubscribed from ProgrammingInterview -
ProgrammingInterview commented 1 month ago
Thank you! That's a bug I will fix asap.
This item has been hiddenIn the future you will only see uploads from ProgrammingInterviewIn the future you will see all activity from ProgrammingInterviewYou have been unsubscribed from ProgrammingInterview -
ProgrammingInterview commented 1 month ago
It should work. It may help reduce the efforts sometimes (e.g. {1,1,1,1,1,1,1} to find 1.). But from the time complexity analysis view, it does not help.
This item has been hiddenIn the future you will only see uploads from ProgrammingInterviewIn the future you will see all activity from ProgrammingInterviewYou have been unsubscribed from ProgrammingInterview -
ProgrammingInterview commented 1 month ago
Actually the if judgment is added to prevent the duplicates (e.g. {1,1,2} we may print "112" twice, but adding this if judgment can help. However, this code to avoid duplicates is not perfectly working need improvement...
This item has been hiddenIn the future you will only see uploads from ProgrammingInterviewIn the future you will see all activity from ProgrammingInterviewYou have been unsubscribed from ProgrammingInterview -
ProgrammingInterview commented 1 month ago
That's a good point. As to print all LIS, we need a collection data structure to store all the possible LIS for each position (ending at that position), other than just recording a single first-met LIS with longest length (which obviously ignore those cases that multiple LISs has same lengths jus...
This item has been hiddenIn the future you will only see uploads from ProgrammingInterviewIn the future you will see all activity from ProgrammingInterviewYou have been unsubscribed from ProgrammingInterview -
ProgrammingInterview commented 2 months ago
Sure, feel free to post it anyway.
This item has been hiddenIn the future you will only see uploads from ProgrammingInterviewIn the future you will see all activity from ProgrammingInterviewYou have been unsubscribed from ProgrammingInterview -
ProgrammingInterview posted 2 months ago
My friends, please find all the source codes at http://goo.gl/fAhQ9. I actually put it in the channel introduction (right side bar). Thanks.
This item has been hiddenIn the future you will only see uploads from ProgrammingInterviewIn the future you will see all activity from ProgrammingInterviewYou have been unsubscribed from ProgrammingInterview -
ProgrammingInterview commented 2 months ago
Thanks. You are right. Actually the title and the test case are different. I should have mentioned this. If you look at the test case in the source code "Ratio of guessing 5 out of 10 is ", so that's the ratio we guess exactly 5 questions out of 10 (p(5)), but the ratio of passing exam (if thresh...
This item has been hiddenIn the future you will only see uploads from ProgrammingInterviewIn the future you will see all activity from ProgrammingInterviewYou have been unsubscribed from ProgrammingInterview -
ProgrammingInterview commented 2 months ago
Well I leave it because I want to make this video searchable, you know, most people use the wrong terms, so catering to the majority mistake is my compromise.
This item has been hiddenIn the future you will only see uploads from ProgrammingInterviewIn the future you will see all activity from ProgrammingInterviewYou have been unsubscribed from ProgrammingInterview -
ProgrammingInterview commented 2 months ago
Actually my code was broken for negative numbers. Thanks to jbdrnzd, I have fixed it in my code, by adding a judging statement to know the sign of the input number and add a minus sign if it's a negative value. Thanks.
This item has been hiddenIn the future you will only see uploads from ProgrammingInterviewIn the future you will see all activity from ProgrammingInterviewYou have been unsubscribed from ProgrammingInterview -
ProgrammingInterview commented 2 months ago
Thanks. I was actually interviewed with this problem before, but that's not a coding questions, instead it's a discussion question after the coding phase. I am sure the code logic can be improved so it's more understandable, but I'd even prefer if some people can paste their own code or some grea...
This item has been hiddenIn the future you will only see uploads from ProgrammingInterviewIn the future you will see all activity from ProgrammingInterviewYou have been unsubscribed from ProgrammingInterview -
ProgrammingInterview commented 2 months ago
Thanks I should have mentioned that I assumed there is no duplicate values. The problem to remove duplicates if there is any in all subsets is much more difficult than this subset problem (unless we are allowed to use powerful data structure like hashmap), and it's more difficult than a similar p...
This item has been hiddenIn the future you will only see uploads from ProgrammingInterviewIn the future you will see all activity from ProgrammingInterviewYou have been unsubscribed from ProgrammingInterview -
ProgrammingInterview uploaded a video 2 months agoThis item has been hiddenIn the future you will only see uploads from ProgrammingInterviewIn the future you will see all activity from ProgrammingInterviewYou have been unsubscribed from ProgrammingInterview
-
ProgrammingInterview commented 2 months ago
I think this is unnecessary. If you look at the source code, it is working fine for your example case. If you test my code and find issue, please let me know.
This item has been hiddenIn the future you will only see uploads from ProgrammingInterviewIn the future you will see all activity from ProgrammingInterviewYou have been unsubscribed from ProgrammingInterview -
ProgrammingInterview commented 2 months ago
You have two ways. First method is to define the list outside of the method, as a class-scope variable, so you can add a permutation to the list whenever you found. Second method is to add a list pointer as part of the parameter for the permutation method.
This item has been hiddenIn the future you will only see uploads from ProgrammingInterviewIn the future you will see all activity from ProgrammingInterviewYou have been unsubscribed from ProgrammingInterview -
ProgrammingInterview commented 2 months ago
It will print 8,4,2,1,2,3,5,9,11,13,15,14,12,8. So 5 will be printed, 6 won't.
This item has been hiddenIn the future you will only see uploads from ProgrammingInterviewIn the future you will see all activity from ProgrammingInterviewYou have been unsubscribed from ProgrammingInterview -
ProgrammingInterview commented 2 months ago
It is O(n), n is the number of tree nodes. Think about worst case you want to find the leaves, you traverse the whole tree.
This item has been hiddenIn the future you will only see uploads from ProgrammingInterviewIn the future you will see all activity from ProgrammingInterviewYou have been unsubscribed from ProgrammingInterview -
ProgrammingInterview commented 2 months ago
That's good corner case! I think when being interviewed with this question, to ask the interviewer whether first (or last) entry can be the balance point will be a good way to show your skill and experience.
This item has been hiddenIn the future you will only see uploads from ProgrammingInterviewIn the future you will see all activity from ProgrammingInterviewYou have been unsubscribed from ProgrammingInterview -
ProgrammingInterview commented 2 months ago
You are right. That's why I added a precision value for controlling the precision loss if there is any. And at the end of the code you may add a judging statement like if(Math.abs(k-(int)k)) < precision, return (int)k. That can solve the issue for those integer squares like 25.
This item has been hiddenIn the future you will only see uploads from ProgrammingInterviewIn the future you will see all activity from ProgrammingInterviewYou have been unsubscribed from ProgrammingInterview -
ProgrammingInterview commented 2 months ago
Well I do not agree with you that dropping the return type will work. You need the return value for output.
This item has been hiddenIn the future you will only see uploads from ProgrammingInterviewIn the future you will see all activity from ProgrammingInterviewYou have been unsubscribed from ProgrammingInterview -
ProgrammingInterview commented 2 months ago
Well, this is "A Interview Question". Regarding performance, worst case is O(N), you are right. But expected performance can be thought of O(N), similar as we thought of quick sort performance as O(NLogN) though worst case is O(N2)
This item has been hiddenIn the future you will only see uploads from ProgrammingInterviewIn the future you will see all activity from ProgrammingInterviewYou have been unsubscribed from ProgrammingInterview
