Image for post
Image for post

As some of my followers, and most of my friends know, I love poker. As an engineer, efficiency and automation are always at the forefront of my mind. Therefore, when playing online poker, I always ask myself: How could I make this more efficient?

Obviously, as a lover of the game, I know that cheating, and especially defrauding my opponents is highly unethical, and simply wrong. I would never use, nor would I provide a full tutorial on how to build one.

Yet whenever I played, this inner anxiousness coupled with curiosity continued to resurface. …


Image for post
Image for post

LeetCode’s challenge of the day on June 15, 2020 (#700) asks us to search a Binary Search Tree and return the node where node.val equals the target value.

To understand why the search in a Binary Search Tree (BST) is so highly efficient, we first need to understand the characteristics of it. A BST consists of nodes that each contain either one, two, or zero children. A node that contains zero children is called a Leaf.

Each node’s left child’s value is smaller than the node’s value, and the right node’s value is larger than the node’s value. …


Image for post
Image for post

LeetCode’s challenge of the day on June 12, 2020 (#380) asks us to create an API wrapper around the standard Swift Set implementation. The only given requirement is that all operations must operate in constant time. We will use a Set as underlying data structure because there is no mentioning of duplication and all operations of a Set are constant by default.

insert(val) will forward to Set.insert and return a boolean indicating whether or not the given value has already been present in the underlying Set.

remove(val) will forward to Set.remove and return a boolean indicating whether or not the given value was inside the Set. …


Image for post
Image for post

LeetCode’s challenge of the day on June 8, 2020 (#231) asks us to write a function that determines if the given Integer n is a power of two. In other words: If we multiply the number 2 any amount of times, will we end up with n?

This is a typical dynamic programming problem. We could solve it with recursion. Using a helper function, we would pass n and the current multiplication. …


Image for post
Image for post

LeetCode’s challenge #102 asks us to traverse a Binary Search Tree in level order. Level order traversal is the key to solve a multitude of tech challenges and comes up in many different varieties within numerous questions on LeetCode.

The idea is: We enqueue the root of the tree into a queue. Within a while loop, we dequeue the root and enqueue each child while maintaining the current level.


Image for post
Image for post

LeetCode’s challenge of June 4, 2020 (#344) asks us to reverse a String. This task can be achieved with 1 line of code, yet it’s worth exploring the different options. Interviewers will want you to show that you can explain different approaches.

Two Pointer Approach

Interviewers very often ask about two pointer approaches, and it’s very likely that you may be asked not to rely on built in functions, which make this solution viable.


Image for post
Image for post

LeetCode’s challenge of June 2, 2020 (#237) asks us to delete a Node from a LinkedList. The tricky part is that we only have access to the Node itself, not to the head or parent Node.

Given the Node 5, as part of the LinkedList (4->5->1->9), we're expected to return (4->1->9) with the Node 5 cut out of the list.


Image for post
Image for post

LeetCode’s challenge #2 asks us to sum up two Linked Lists and return one singly Linked List. The given lists are (2 -> 4 -> 3) and (5 -> 6 -> 4), and the expected return list is (7 -> 0 -> 8).

The Brute Force Solution

The brute force solution for this problem is not really worse than the optimized solution. Both have a space and time complexity of O(n) where n is the combined nodes in both lists.

The difference between the approaches is the unnecessary overhead of the first one. Swift does not come with a native LinkedList, therefore one would have to implement the traversal, then traverse both lists to get two integer arrays and then sum up the elements. …


Image for post
Image for post

The two sum problem is a classic coding challenge required in many tech interviews, and the #1 challenge on leetcode.com.

Usually, one is given an unsorted array of integers and a target integer. In this scenario, your goal is to write an efficient algorithm that returns if there are two elements in the array that add up to the target. You are required to either return the indices or the integers themselves.

The example in this post assumes that there will be an answer and there will only be one pair that sums up to the target.

In your potential interview, it is important that you specifically ask your interviewer if they would like you to return all pairs, only the first pair, or what they want you to return if there is no pair at all.


Image for post
Image for post

In this article I will explain how to get the names of the city, country, zip code, etc from a geo location object and the other way around.

The first thing we need to do is to set the needed permissions into the Info.plist file to be able to ask the User to access the GPS module of this phone. Open the Info.plist and set the following.

About

David Seek

Software Engineer at Amazon (Alexa Mobile)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store