Posts

Showing posts from December, 2024

Follow the hints! - Part 5

Image
In this problem the hints are very useful: first, make a hash table (or set) to access the elements of the array quickly. Second, try every element as if it was the outlier, do some math manipulation to check if that element is a valid candidate, and if so keep track of the max. Notice that you achieve linearity with multiple 1-passes. Code is down below, cheers, ACC. Identify the Largest Outlier in an Array - LeetCode 3371. Identify the Largest Outlier in an Array Medium 68 9 Add to List Share You are given an integer array  nums . This array contains  n  elements, where  exactly   n - 2  elements are  special  numbers . One of the remaining  two  elements is the  sum  of these  special numbers , and the other is an  outlier . An  outlier  is defined as a number that is  neither  one of the original special numbers  nor  the element representing the sum of those numbers. Note  ...