Salesforce Category

Apex Coding Interview Challenge #11

Given an integer k and a string s, find the length of the longest substring that contains at most k distinct characters. For example, given s = “abcba” and k = 2, the longest substring with k distinct characters is “bcb”. Solution Testing

Rate this:

Read More

Apex Coding Interview Challenge #1

This question was asked during an Amazon interview Following schema is provided: Account Total_Salary__c (Number) Max_Salary__c (Number) Account_Salary__c Account__c (lookup) Name (String) Salary__c (Number) An Account can have multiple Account_Salary__c records that lookup to an Account by the Account__c. Write a trigger that would update the Account Total_Salary__c, Max_Salary__c when a new Account salary record […]

Rate this:

Read More

Salesforce System Integration Interview Prep

Remote Process Invocation – Request and Reply Best solutions External Services – invokes a REST API call – allows to invoke externally hosted service in declarative manner. External REST service are available in a an OpenAPI or Integrant schema definition. Contains primitive data types, nested objects not supported. Transaction invoked from Lightning Flow. Integration transaction […]

Rate this:

Read More

Apex Coding Interview Challenge #5

Given an encoded string, return its decoded string. The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. Note that k is guaranteed to be a positive integer. DecodeHelper class DecodeHelper Test

Rate this:

Read More

Apex passing parameters to Batch job during scheduling

Here it the use case: You have 1 job that you want to run weekly and monthly but the monthly job also has to generate a notification. You don’t need to create two classes but can pass a parameter to the schedule to know it is a weekly or monthly job. The batch Job class […]

Rate this:

Read More

Apex Cache Tracker to remove session cache

Here is the problem that needed to be solved: 1. Use session cache to cache some user information like their profile or user settings 2. When a external systems update the information and try to remove the session cache as it got updated it fails because it does not have access to a users session […]

Rate this:

Read More

Apex Coding Challenge Find Highest Frequency of Numbers

Problem: Find the number that has the highest frequency in a list of integers. Input: 1,6,2,1,6,1 Output: 1 //because 1 occurs 3 times in the list Option 1: Use Hashmap to iterate list Option 2: Use wrapper class with compare to sort wrapper Option 3: Using buckets to group index of frequencies together

Rate this:

Read More

Apex Clear all fields for a SObject record

The clearOutRecords would iterate all the fields passed as the currentRecord, then: 1. Exclude the fields as part of the fieldsToExcludeForClearOut Set and relationship fields 2. Check if the field is not null and updateable 3. Special logic to set fields to predefined values 4. Set all other fields to null 5. Return the SObject […]

Rate this:

Read More

Apex remove sensitive data from json

When you need to remove sensitive data from json before logging the following method will remove a predefined list of keywords removeAttributes method will iterate all the keys in the payload and remove the sensitive keys from the payload

Rate this:

Read More

Apex Coding Challenge for Iterating Lists

Here is the problem statement: Given an expectedSum value find the sum (n+ (n+1) = expectedValue) from a list that equals the expectedSum. I am using the following list 1,3,4,4,5,9 and looking for the sum to be 8 (3+5, 4+4) *Note the list is sorted Solution 1: The above time complexity for a nested for […]

Rate this:

Read More