Posted on July 16, 2020 Leave a Comment

Follow these steps to install nvm using homebrew https://www.wdiaz.org/how-to-install-nvm-with-homebrew/ Confirm echo $HOME/.nvm returns /Users/{your username}/.nvm Now let’s edit zshrc to add nvm bash_completion vi ~/.zshrc Add the following lines to the top of the file Note: Make sure you add this snippet before any call to compdef else you will still see the error Reload […]

Posted on July 7, 2020 Leave a Comment

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

Posted on July 6, 2020 Leave a Comment

Given a string of round, curly, and square open and closing brackets, return whether the brackets are balanced (well-formed). For example, given the string “([])[]({})”, you should return true. Given the string “([)]” or “((()”, you should return false. There is are Stack implementation currently available in Apex so we can use a List to […]

Posted on July 6, 2020 Leave a Comment

Given a list of integers, write a function that returns the largest sum of non-adjacent numbers. Numbers can be 0 or negative. For example, [2, 4, 6, 2, 5] should return 13, since we pick 2, 6, and 5. [5, 1, 1, 5] should return 10, since we pick 5 and 5. Follow-up: Can you […]

Posted on June 29, 2020 2 Comments

Implement an autocomplete system. That is, given a query string s and a set of all possible query strings, return all strings in the set that have s as a prefix. For example, given the query string de and the set of strings [dog, deer, deal], return [deer, deal]. Hint: Try preprocessing the dictionary into […]

Posted on June 25, 2020 Leave a Comment

Given an array of integers, find the first missing positive integer in linear time and constant space. In other words, find the lowest positive integer that does not exist in the array. The array can contain duplicates and negative numbers as well. For example, the input [3, 4, -1, 1] should give 2. The input [1, 2, 0] should give 3. […]

Posted on June 24, 2020 Leave a Comment

Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original array except the one at i. For example, if our input was [1, 2, 3, 4, 5], the expected output would be [120, 60, 40, 30, 24]. If our input […]

Posted on June 19, 2020 Leave a Comment

Given a list of numbers and a number k, return whether any two numbers from the list add up to k. For example, given [10, 15, 3, 7] and k of 17, return true since 10 + 7 is 17. Bonus: Can you do this in one pass? Solution Test Complexity Analysis Time complexity: O(n) […]

Posted on June 18, 2020 1 Comment

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 […]

Posted on June 3, 2020 Leave a Comment

Pass by value – all primitive data type arguments, such as Integer or String, are passed into methods by value. This means that any changes to the arguments exist only within the scope of the method. When the method returns, the changes to the arguments are lost. Non-primitive data type arguments, such as sObjects, are […]