Google Coding Interview P2 | By Salesforce Engineer

Sdílet
Vložit
  • čas přidán 11. 04. 2020
  • #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 1 of this interview here: • Google Coding Intervie...
    Check out the interview doc here: docs.google.com/document/d/16...
    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

Komentáře • 41

  • @SFDCFacts
    @SFDCFacts  Před 4 lety

    ****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!!!!!

  • @kirillhantayev9627
    @kirillhantayev9627 Před 4 lety +9

    This problem has a very simple mathematical solution. Instead of retrieving all patients for an area just keep adding the number of cases to a custom field on the area. Than calculate the weighted average each time just with the trigger context - without doing any additional SOQL queries.

  • @MichaelJohnson-ot3if
    @MichaelJohnson-ot3if Před rokem +1

    Crazy thing is this can all be accomplished in a much more efficient manner with a few additions to the data model and a simple workflow (or few lines of trigger code if you must). I understand this is a coding interview, but I find far too often Salesforce developers(and developers in general) immediately start with over-engineered coding implementations as opposed spending some time thinking about the problem, and implementing a more simplistic elegant solution. I think an important follow up question may be "would you be able to implement this without code, and what are the pros and cons of each?" which will definitely give you some insight into how the developer approaches problems.

  • @hamarecutefunnykids2418

    Good Work @SFDCFacts, Please keep posting these kind of videos.

  • @sumanthsf9819
    @sumanthsf9819 Před 4 lety

    Amazing Video format watched many SFDC videos but this is very interactive and thorough.

  • @nareshvarma9091
    @nareshvarma9091 Před 4 lety +2

    Nice approach .First thought after avg problem ,I was thinking of using sub query but time complexity O(n2) . optimum solutions at end are very nice keep good work going 👌

  • @shivanichoudhary2345
    @shivanichoudhary2345 Před 4 lety +1

    Good work Manish! 👍🏻👍🏻

  • @rosunilck
    @rosunilck Před 4 lety +1

    Awesome Explanation Bro....

  • @arpitasam9216
    @arpitasam9216 Před 3 lety +1

    Thanks for sharing this type of conversation in an interview (mock interview). There are lots of video for salesforce related topics. But hardly we get few like this to get idea about interview process for experienced . Thank you so much.

  • @dheerajpandey2580
    @dheerajpandey2580 Před 4 lety +8

    You can create formula field to get days between created date and cure date and then you can use aggregate query :) No need to iterate on trigger new much time you are consuming unnecessary space Awesome video (y)

    • @MariappanPerumal
      @MariappanPerumal Před 4 lety +2

      This way is much better than what they are doing.

    • @hamarecutefunnykids2418
      @hamarecutefunnykids2418 Před 3 lety

      Exactly, I was also thinking the same way. Not sure why Ranjan did not go that way.

    • @SFDCFacts
      @SFDCFacts  Před 3 lety +5

      Just to reply everyone on this thread, this was a coding interview and follows similar pattern of how product companies take interviews. The objective of these interview is to check your coding abilities and your knowledge of data structures and algorithms, hence you are not allowed to make config level changes.
      But that’s not all, we have discussed this approach as well in the end of part 2 video of this interview.
      Happy learning!!

  • @shri2113
    @shri2113 Před 4 lety +2

    Nice video Manish.. Keep it up.
    One request from my side, if you can make a kind of tutorial video on how to measure complexity of code, it would be really great.

  • @anirudhbandi8665
    @anirudhbandi8665 Před 4 lety +8

    Ranjan directly subtract date..it won't work..we have to use daysbetween() method to calculate days...apart from that 👍

  • @AshishSharma-mn6uc
    @AshishSharma-mn6uc Před 4 lety +1

    Nice glasses Manish 👍

  • @sumitabsaxena349
    @sumitabsaxena349 Před 3 lety

    Hey Manish, Can you please suggest what are the limitations in aggregate query that you were discussing?

  • @chandrasekharmedisetti7507

    Calling multiple times would end up with query limit.feature we can't pass other than primary parameters.

  • @purvasharma5621
    @purvasharma5621 Před 3 lety

    34:00 are we allowed to use formula fields on aggregate queries?

  • @snehabhatkande4416
    @snehabhatkande4416 Před 2 lety

    Is there any video explaining the DSA roung at google for salesforce developers ? how hard the questions are?

  • @nikhilmhegde
    @nikhilmhegde Před 3 lety

    I think this can be solved very easily. A trigger on the Patient object to update the cured Days or fatal Days whenever the state change happens. Then on the Area object, we would require four Roll-up summary fields, one for total CuredDays, one for total fatalDays, one for the number of cured patients, and one for the number of fatal patients. Then we can create two formula fields to calculate the average fatality rate and average days to recover. Again for this to work we need a master-detail field for this.
    Like if this solution works.

    • @kd-1-9942
      @kd-1-9942 Před rokem

      He said lookup so that he wants to avoid Summary fields as solution but that should be a question to the interview that why not master detail field.

  • @alok7049
    @alok7049 Před 3 lety

    I think group by rollup would do the purpose in trigger after update context, writing so much logic is fine but I think using queries capabilities will simplify. above solution works only when it was built in the starting but later if already had so much data/patients in the area...considering the volume...above solution will not work. we have to use either queries capability or async queries/batch- this is also an example of non-real time processing, need not to be real time.

    • @SFDCFacts
      @SFDCFacts  Před 3 lety

      No configuration is allowed, specially the rollup summary, that's the whole point of a coding interview (to test your coding abilities)

  • @rajvora5753
    @rajvora5753 Před 3 lety

    Are the interview questions related to salesforce object model like shown in the video or could the coding interview questions be related to something from HackerRank or Leetcode google interview questions?

  • @venumadhavsamala3775
    @venumadhavsamala3775 Před 3 lety

    Why exactly can't we use Batchable and Future and we stuck to using Queueable?
    Can someone explain?

  • @shivanisoni3031
    @shivanisoni3031 Před 4 lety +1

    Amazing content. Kindly make a video explaining how to measure complexity of the code.

  • @kumudthakur3540
    @kumudthakur3540 Před 4 lety +1

    Nice work.. just a thought as you mentioned about custom field. Instead of lookup will create master detail relationship and roll up the formula field. Secondly, if area having more patients like 20000 it may lead to lookup skew issue I guess.

  • @SarGuP
    @SarGuP Před 3 lety

    formula field on child and roll-up summary on parent would be the best approach.

    • @anuragpalivela2898
      @anuragpalivela2898 Před 3 lety

      Formula fields that include date values are forbidden for the roll up summary fields. The optimal solution would be to create formula fields to calculate no of days to cure and no of days to fatality and use aggregate soql query like Manish said: may be something like this
      Fields on patient__c object:
      NoDaysToCure__c, NoOfDaysToFatality__c
      List agr = [select Area__c, avg(NoOfDaysToFatality__c), avg(NoDaysToCure__c) from patient__c group by Area__c ];

  • @kumar.anupam
    @kumar.anupam Před 4 lety

    Can it be done without trigger?

  • @arijitnagchowdhury3740

    nice explanation but why this can not be managed by Batch.

    • @SFDCFacts
      @SFDCFacts  Před 4 lety +1

      We have discussed this at the end of part 2 of this interview.

    • @prashantyadav7981
      @prashantyadav7981 Před 3 lety

      @@SFDCFacts - it can be done using the aggregate result for average.

  • @ManishKumar-th3cw
    @ManishKumar-th3cw Před 2 lety

    Just a quick thought instead of using the Map mapAreaToCuredAverage = new Map(); and Map mapAreaToCount = new Map();
    Why not create a single map
    Map mapAreaToCuredAverage = new Map();
    and doing so will help to add the diffStateChange value along with no. of patients associated with a particular area.
    In the end we can get the avg time to cure by simply adding the (values in the list of Integers / size of that list)
    It would save using another map and the other Iterations done!.
    Let me know if I missed anything here.