Google Coding Interview P1 | By Salesforce Engineer
Вставка
- Опубліковано 7 жов 2024
- #SalesforceCodingInterviews #SFDCFactsAcademy
Here we are with yet another coding interview for Salesforce Developer position. The interview pattern is very similar to how major product companies like Google, Amazon, Salesforce, Uber etc conduct their interviews and you will be seeing similar problems in your interviews.
In this video, I paired up with Ranjan Kumar Saha who is an Ex-Salesforce employee and has been working on Apex for the last 7 years.
Check out part 2 of this interview here: • Google Coding Intervie...
Check out the interview doc here: docs.google.co...
Follow Ranjan on LinkedIn here: / ranjansaha04
Become a patron and support my work here: / sfdcfacts
Please share this video and subscribe to the channel if you love my content.
Content By: Manish Choudhari & Ranjan Saha
Editor: Manish Choudhari
Website: sfdcfacts.com
Twitter: / manish_sfdc
LinkedIn: / manish-choudhary
****FREE LWC COURSE VOUCHER*****
Are you someone or do you know someone who recently appeared for a Salesforce Developer interview at Google/Amazon/Uber/Salesforce or any major product company?
Then reach out to me at *sfdcfacts@**gmail.com* to share your interview experience and get access to LWC udemy course for FREE!!!!!
Did you really expect him to write code? Would it be fine to provide high level solution without coding?
I think it is easy to add 2 formula fields in Patient Object for Days to Cure and Days to Fatal . Use Aggregate Query by Count( id) and SUM( days to Cure ) and Sum ( days to Fatal ) group by Area and Status. This should be 5 lines of code in Trigger.
Exactly...
I think this may work
List aggrPatient=[SELECT Id, State, SUM(NOD_Recover__c)/count(Id) AvgRecover, SUM(NOD_Fatality__c)/count(Id) AvgFatality, areaId
FROM Patient Where Id IN:Id && areaId IN:areaId
Group By areaId]
NOD_Recover__c and NOD_Fatality__c both are Formula fields on Patient object.
The most useful information ever i seen on youtube regarding salesforce. please keep making these kind of videos. Thanks
Good content.. i would like to see more complex problems in next interviews..
Love your videos..!!
Nice video manish..but i think if you are making this video for google coding round ..i would suggest to increase the complexity of the problem as these seems pretty simple rollup summary field implementation of finding the average functionality in lookup relationships.
Very helpful for the preparation of my next interview.
What about having a formula field to calculate days and get the AVG directly in the SOQL? Keep in mind that what is shown in the video might fail if there are more than 50k patients
Thanks
You are correct on both points Luciano and we have discussed both of these point at the end of part 2 of this interview. We have also discussed the alternative approaches, trade offs etc.
Very helpful. Waiting for more complex scenarios in upcoming videos. 👍🏼
Great video, thanks for sharing it ! If the objective was to display the averages fields on the Area__c details page or a LWC, why not use an attribute with a getter on the controller returning an aggregate soql result? If you are allowed to create a custom field before hand, this seems to be a more elegant and scalable solution.
Instead of writing avg logic in trigger we can create formula field on patient object and using trigger we can directly sum the time and set the Avg on parent object
Parent object means area
Thanks for sharing the live coding interview.
Your videos inspire me a lot.
Planning to share my interview Experience as well.
Hi,
Please write to me at sfdcfacts@gmail.com, happy to talk further.
thanks manish for wonderful coding interview session
Thank You sir for posting these interview sessions. It will help us a lot. 👍
Ranjan directly subtract date..it won't work..we have to use daysbetween() method to calculate days...apart from that 👍
Thanks alot. God bless you
I think Formula fields on Patient to calculate recovery days and fatality days and two roll up summary fields to calculate average of recovery days and fatality days would work. we don't need trigger for that.
It's a lookup, not a master details
Sir please tell should I learn Java or apex language for salesforcedevelopment.
Can you guide how to improve more on Trigger logics and approach .
Awesome
Is it true that product based companies like Google and Amazon etc take a Data Structure coding first and then Salesforce interview later?
Please let me know whether this is myth or fact.
Thanks 😊
True, yes dsa and algo is the initial round there
Super duper , great
Why not masterdetail relationship and a formula field on patient and then rollup summary on area
Thank-you sooo much
Very Helpful Video
Bro simply create a formula field on child object and use aggregate result function using avg it is 4 line of code do not do all this step
Hii..Once pls share the code with formula field on child object..
What is meant by read only mode?? What i can see that the code hasn't been properly bulkified and you would be hitting governor limits after the insertion.
Is this google interview question or general interview?
I see a big gap in the approach. @ranjan has not considered about the existing patients. His code will only work for the patients whose state changes and i can see the average will be messed.
I liked the approach through he should have first written the psedu code first.
Agree with you on the case of existing patients (Y)
Good point Lokesh, but I think this approach will work even for existing patient records as well, as Ranjan is getting the parent area records first and then getting all patient records of these areas (including existing records).
So while calculating the average, all patient records will be considered.
Also, in part 2 (will be publicly available tomorrow), we have discussed other approaches as well, like having a batch in place to update these records.
If you observe the SOQL written in the service class has a set of Patient IDs that are updated but not all the existing patients. In order to calculate the average we have to sum the time value of each patient and divide by total number of cured patient. This will also help incase patient State changed from cured to fatal.
By the way I liked your question and awareness towards COVID 19.
Keep it up 👍
@@lokeshkumar3163 in that soql he took set of all patients related to area.
at 7:36, you mentioned that for 10 patients an average would be 15 (considering some patients take 10 days and some 20). Shouldn't we consider the total number of patients while calculating average? ex: (sum of recovery days) / (total number of patients)...instead of total days /2
That is what I meant.
10 patients
5 patients with recovery days 10= 50 days
5 patients with recovery days 20 = 100 days
150/10 (sum/total patients)= 15 😂
Hi Manish,
What about when a patient record is deleted/undeleted. Don't we have to adjust the average field on Area record?
We discussed this in the video Prabhdeep, as per the problem statement, the deletion of a patient record is not allowed.
The second question is incorrect logically, An area can have multiple patients but a patient cannot be from multiple areas.
Would my approach be termed " not using best practices" if i don't implement a trigger factory but still make handler for the trigger?
He can get that count from the size of that list of integers
Title is totally misleading.Have you been interviewed with Google? (they never ask this type of question)
So what do they ask?
Hi Arpit, yes, I have been interviewed and have many friends in Google, and this is precisely the type of questions they ask. Please share your experience as well if you have been interviewed or working at Google, I would love to share that with everyone.
They don’t ask these type of question like you asked, they asked mostly algorithms related question which we need to solve.If you have seen video people posted on youtube or go to leetcode or geeksforgeeks or interviewcup, you will get to know what is the question generally they ask at high level
And also related to system design, it’s not straightforward question basically they expect you to come out with high level design and then deep dive into it
Yeah, true. But if you apply for a Salesforce Developer Position (the video title also has it), then the questions are different, they test your algorithms and DS knowledge on Salesforce platform.
If you apply for a software engineer role (backend engineer, or front end engineer), then they test you with more generic algorithms which you can also find on leetcode, interviewbit etc.
So as the title says, this video is for Salesforce Developer position at Google.
And just for the reference, I have gone through the complete interview process at Google, Amazon and Salesforce, and sharing only genuine details here.
I have gap 2 years how can I go as a fresher for salesforce developer less opportunities for freshers what can I do
Sir ,should i learn core java , befor i lean Apex
please share scenario based interview question on sharing and workflow as well others.
How can I go as a fresher as a salesforce developer fresher has lless opportunities can I wait my gap is so long what can I do
can u Show w some project examples coding
can i get job as a fresher if yes how should i apply for that and if no please help me what should i do.
Since its a lookup can we not use aggregateresult?
we can use in any kinda relationship , in look up relationships we cannot create roll up summaries