Posts for: #LeetCode

LeetCode – Two Sum II

Hey there! Today, let’s dive back into the world of LeetCode problems with Swift. After successfully conquering the Two Sum problem, we’re geared up to take on the next challenge: Two Sum II. To make things interesting, let’s explore this problem using a two pointers technique. Ready to tackle it together? Problem We are given an array of numbers sorted in non-decreasing order (this means each element is greater or equal to the preceding one) and a target value.
Read more

LeetCode – Two Sum

Let’s continue working with more LeetCode problems, this time focusing on an easy one. We need to find if, in a given array, we can find two numbers such that they can be added up to a certain target value. We can be certain that there will be only one solution. Solution Brute force As with other problems, one first approach would be to compare all possible combinations to find the two numbers that adds to the target.
Read more

LeetCode – Contains Duplicates

Hello everyone, in this post I want to explore a solution to the Contains Duplicates LeetCode problem using Swift. Most solutions use Python and I think it would be a good idea to try to use Swift to explore how well it behaves for the LeetCode style questions. The Problem This problem states that we have an array of integers and it may contain some values that are duplicated, so we need to write a function that check if the given array contains any element more than once.
Read more