Hey, I'm a big fan of your channel and really enjoy your tutorials . I have an idea for a video tool that I think your viewers might find interesting. Would you be open to discussing it further and potentially creating a video about it on your channel? Let me know if you're interested!
@hariharaprasad1252Күн бұрын
epic intro
@cursed_nerdКүн бұрын
I wasted 4 hours
@AlgorithmistКүн бұрын
How did you do today?
@arindampande2686Күн бұрын
What an intro 😮
@anmeluzКүн бұрын
You found the trick so quickly... I need to really dive deeper into constraints
@AlgorithmistКүн бұрын
Were you able to divide this tree up?
@krityaanКүн бұрын
Epic intro
@elliancarlosКүн бұрын
Does this code still works? Right now I've made one similar that failed to some test cases. This was because that are individual components that can be break down from the parent down (like cutting a linked list in half) and those would be two divisible components and nor "none" or one.
@elliancarlosКүн бұрын
To fix this you can return directly into the go function check if a partial sum of a component is divisible and sum it to the answer
@slippy40062 күн бұрын
Love the content! Found this channel recently and the explanations of your thought process in real time have really been helping me with my own competitive programming goals. Cheers!
@Algorithmist2 күн бұрын
How did you do today?
@Algorithmist2 күн бұрын
Were you able to get to a tree?
@Mianesy2bd2 күн бұрын
nah coding inside of a plane is crazy bro!
@RyanPhung7252 күн бұрын
more airplane vids! XD
@Algorithmist2 күн бұрын
How did you do today?
@Jazzimus3 күн бұрын
the "no infinite money loops" thing and low number of nodes hinted floydwarshall to me, which imo is the easiest to implement since its just 3 for loops.
@bufdud43 күн бұрын
Your python code still accepts, and actually faster than 70%...
@Algorithmist3 күн бұрын
How chunky did you find this problem?
@karanchaudhary48323 күн бұрын
little bit
@karamany98703 күн бұрын
I finally solved the 2nd part lol. How would it compare to leetcode problems?
@ez75324 күн бұрын
Thank you, Larry
@Impromptu214 күн бұрын
Love your raw thinking and streams.
@rishikumar2184 күн бұрын
Thanks a lot: here is JAVA code: class Pair <T,U>{ T first; U second; Pair(T first,U second){ this.first=first; this.second=second; } } class PqComparator implements Comparator<Pair<Long,Integer>> { public int compare(Pair<Long,Integer> p1,Pair<Long,Integer> p2) { // Compare first elements if (!p1.first.equals(p2.first)) { return Long.compare(p1.first, p2.first); } // If first elements are equal, compare second elements return Long.compare(p1.second, p2.second); } } class Solution { int MOD=(int)1e9+7; private Long pow(int x,int n){ if(n==0) return 1L; if(n==1) return (long)x; Long half=pow(x,n/2); Long ans=((half%MOD)*(half%MOD))%MOD; if((n&1)==1) ans=((ans%MOD)*(x%MOD))%MOD; return ans; } public int[] getFinalState(int[] nums, int k, int multiplier) { if(multiplier==1) return nums; // pq of nums ele and index PriorityQueue<Pair<Long,Integer>> pq=new PriorityQueue<>(new PqComparator()); ArrayList<Long> ans=new ArrayList<>(); long max_ele=0; int n=nums.length; for(int i=0;i<n;i++){ pq.add(new Pair<>((long)nums[i],i)); max_ele=Math.max(max_ele,nums[i]); ans.add((long)nums[i]); } while(k>0){ Pair<Long,Integer> top=pq.poll(); if(top.first==max_ele){ pq.add(top); break; } top.first*=multiplier; ans.set(top.second,top.first); pq.add(top); k--; } // do for cycle and leftover int cycle= k/n; int leftover= k%n; System.out.println(cycle+ " " + leftover); // leftover ArrayList<Integer> order=new ArrayList<>(); while(!pq.isEmpty()){ Pair<Long,Integer> top=pq.poll(); order.add(top.second); } int i=0; while(i<leftover){ int idx=order.get(i); ans.set(idx, ((ans.get(idx)%MOD)*multiplier)%MOD); i++; } // cycle multiplier^cycle for(i=0;i<n;i++){ ans.set(i,(((ans.get(i)%MOD)*(pow(multiplier,cycle)%MOD))%MOD)); nums[i]=(int)ans.get(i).longValue(); } return nums; } }
@Algorithmist4 күн бұрын
How did you do today?
@cursed_nerd4 күн бұрын
good day, only 30 minutes
@sourabhkhandelwal6894 күн бұрын
pretty easy today.
@Algorithmist4 күн бұрын
Were you able to get a good final price?
@mortysanchez3614 күн бұрын
larry please publish your notes/learnings. it will be very helpful for learners.
@prashant68444 күн бұрын
I think the issue is that it is not typical FFFFTTTT and so binary search may not be applied directly? If your segments are too many, it won’t be T as each of your segment should be exactly limit except for the last segment.
@AbhinavPundhir4 күн бұрын
How many years of practice did it take you to be this good at problem solving??
@rijumondal68765 күн бұрын
I am not even worthy to see this channel !
@Algorithmist4 күн бұрын
put in the work!
@nakulgoyal28795 күн бұрын
Did you repeat yourself?
@cursed_nerd5 күн бұрын
AOC is getting serious
@Algorithmist5 күн бұрын
How did you do today?
@yashwantmoharil58925 күн бұрын
Did you repeat yourself?
@thomasc75265 күн бұрын
Did you repeat yourself?
@Algorithmist5 күн бұрын
Did you repeat yourself?
@khoilin05 күн бұрын
Would love to learn more about the idea of thinking about sliding windows as "contribution of ith index", do you have another clip of you going over this?
@tylermmalone5 күн бұрын
You a Marine Larry? Love your solutions and explanations
@Algorithmist4 күн бұрын
no! I ran the Marine Corps Marathon though!
@tylermmalone4 күн бұрын
@ oh alright, hell yeah man
@manoor08586 күн бұрын
hii can u make a video on tips for excelling in contests, and how should beginners start giving contests and ur thought process when u see a question with some examples
@Algorithmist4 күн бұрын
a lot of it is practice, practice - when you're a beginner, everything you do helps, so just do anything!
@manoor08584 күн бұрын
@@Algorithmist 👍😁
@dhanvishyam83866 күн бұрын
heyy i couldn't understand what type of problem it was. I was confused when someone commented that this was a graph problem. How did you identify that this was a graph problem
@ManishKumar-kw7qe5 күн бұрын
hints:1.look at the language of the questions--> it is very similar to a graph question " that you can convert from startCurrencyi to targetCurrencyi at a rate of rates1[i]" it is similar to you can move to node v from node u at a cost of c. 2.-->at the last you want the maxAmount of a src node (initialCurrency) this pattern is more similar to shortest distance questions,although it is not a one out of them because here we have to maximise something
@SKcoder-n7h6 күн бұрын
I just put 60 sums ,56 from easy and 4 from medium, it is taking atleast 10 minutes for a sum, will reach 200 sums??
@Krishnakantydv6 күн бұрын
i tried this N2 solutoin, 530 test case passes, it fails for input; [0,0,0,0,2,2,0,1,2,1,2], expected is 19, but my soluton returns 18. I cant even see the 19th split manually. Here is the code: class Solution { public: int beautifulSplits(vector<int>& nums) { int n = nums.size(), count = 0; string total = ""; for (int i = 0; i < n; i++) { total += to_string(nums[i]); } for (int i = 0; i < n - 2; i++) { string str1 = total.substr(0, i + 1); // Check for match in the first intersection if (i <= (n - 3) / 2) { if (str1 == total.substr(i + 1, i + 1)) { int k = n - 2 * (i + 1); if (k > 0) { count += k; } continue; // No need to check second joint for this `i` } } // Check for match in the second joint for (int size = 1; size <= (n - i - 1) / 2; size++) { string str2 = total.substr(i + 1, size); if (total.substr(i + 1 + size, size) == str2) { count++; } } } return count; } }; I would appreciate a little help in spotting the problem.
@Algorithmist5 күн бұрын
for small inputs, just run an N^3 solution and then compare your solution to it - so basically you are writing a verifier to help yourself debug
@Algorithmist6 күн бұрын
How did you do today?
@SKcoder-n7h4 күн бұрын
@@Algorithmist Today I done 2 sums
@dank70446 күн бұрын
I did it in C++, and it overflowed in the simulation part lol. Even after using long long.
@Algorithmist6 күн бұрын
Are you able to get to your final state?
@akshatgupta10926 күн бұрын
looked bfs but was easy lol
@nhienle51377 күн бұрын
Lary is rock yesterday, I'm 1/4 at 2k2, rip my rank 😂
@santali-tr3rj7 күн бұрын
class Solution { public: int makeStringGood(string s) { //delete everything int fre[26]={0}; for(int i =0 ;i<s.size();i++) fre[int(s[i]) - 97]++; //hint is complexity = O(26 * N) // 2nd hint , operate on fre[26] to make 0 or c // agar if u do third operation then previous has to be deleted only - 3rd hint //try 1 to s.size() as the value of c //hint from LC - delete somebody by +1 and promte it can be done at arriving on the elements by +1 //min(s.size() , max(fre[i])) int ans = INT_MAX; for(int c = 0;c<=s.size();c++) { int dp[26][2] ={0}; dp[0][0] = fre[0]; if(c>=fre[0]) dp[0][1] = c- fre[0] ; else dp[0][1] = fre[0] - c; for(int j = 1;j<26;j++) { if( c >= fre[j] ) dp[j][1] = min( dp[j-1][1] + max(0 ,c - fre[j] - max( 0 , fre[j-1] - c) ) , dp[j-1][0] + max(0 , c- fre[j] - fre[j-1]) ); else dp[j][1] = min(dp[j-1][1] + fre[j] - c , dp[j-1][0] + fre[j] - c ); dp[j][0] = min( dp[j-1][0] + fre[j] , dp[j-1][1] +fre[j] ); } ans = min({ans , dp[25][0] , dp[25][1]}); } return ans; } };
@santali-tr3rj7 күн бұрын
i tried greedy but failed, try all divisors of 1 to s.size() and then 26*26 , taking out which character is better to keep first decide
@bhanupratapsinghrathore64637 күн бұрын
Thanks for the code. Your bottom up code beats 100%.