Posts

Showing posts from March, 2022

IP#4 : LinkedList improvement

Image
 LinkedList improvement Ashur Baroutta     In the previous submission, we worked on a LinkedList problem and got our solution to a point where the run time was very fast, though our memory management was ranked quite low in comparison. That didn't sit well, so today we try to tackle optimizing it in terms of memory efficiency. Our original solution for the problem, deleting duplicates, is as follows. So while the solution is acceptable, it exposed a weakness in my line of thinking. Fewer lines of code, or fewer words, does not inherently mean fewer resources utilized while code is compiled and executed. It seemed natural to think but I need to break this idea.  After working through different types of solutions and researching a better way to solve the problem in terms of speed and memory usage. I was able to manage the following.  Originally, I just started with one node and iterated through the list with a basic while loop. This time, what I did is had a node ...

IP#3 : LinkedLists Intro

Image
                                LinkedList Intro                                                                                 by Ashur Baroutta      Following up on our interview prep, while we are still working on numerous array problems, it's time to explore the LinkedList data structure problems and start building a strong foundation for those types of use cases. A LinkedList data structure is a list consisting of nodes where each node contains both a data field and a reference(link) to the next node in the list.      In the same spirit of our other submission, we will start with a problem statement that says "Given the he...

Interview Prep #2 : HashSets and Intersection

Image
 Interview Prep #2 : HashSets and Intersection by Ashur Baroutta      Continuing to explore different problems and tools to solve them, we follow up HashMaps with HashSets. A HashSet is simply a collection of unique objects, and because it only holds unique objects it allows us to add, remove, and check if an object is within the set in constant time. It differs from a HashMap in that it doesn't contain key-value pairs as by nature it cannot have more than 1 unique element, so an element essentially acts as its own key within a set.     HashSets allow us to use Intersection (set1.intersection(set2)) or (set1 & set2) (& being the intersect operator in python), allows us to pull shared elements from the sets.     Our problem asks us "Given two integer arrays nums1 and nums2, return an array of their intersection. Each element in the result must be unique and you may return the result in any order."      We could use a loo...