Balanced Parentheses in Strings

Today, I’d like to present a small algorithmic problem and some solutions I have come up with. The problem is as follows: Given a string, determine if the parentheses are balanced. Balanced parentheses mean that for every ( found, there must be a corresponding ) to balance it. Input and output It is guarantee that any given string will contain at least one parenthesis. in: "(hello" out: false in: "(hello()world)()" out: true in: "hello()(())" out: true in: "()" out: true in: "(" out: false Solutions Using a Hash Table (Dictionary) Let’s try a simple approach using a hash table.
Read more

Working With Git Submodules

The other day, I was working on a project that had a Git submodule. Initially, I found it a bit tricky to make it work, so I decided to create a short tutorial on this. What is a Git submodule Essentially, a Git submodule is a way to include one Git repository inside another Git repository. This creates a nested structure. So, in simple words, a Git submodule is like a mini Git repository that you can include in your main Git repository to use and update external code or resources without actually putting all of their files directly in your project.
Read more

Replacing Elements in a String

One of the most common problems we face when working with strings is modifying certain characters in the string. This problem can be easily solved with the use of regular expressions (regex). Before Swift 5.7 If you can’t uae the newest Swift you can achieve this by using the method replacingOccurrences(of:with:options). Here is an example of its use: let s = "12abc34" let t = ss.replacingOccurrences( of: "[a-z]", // regex with: "", options: .
Read more

SwiftUI – Horizontal Pages Carousel

Horizontal page carousels are a common element in iOS interfaces for presenting pages in a horizontal, swipeable format. They are particularly useful for showcasing views with varying content. Code In SwiftUI, creating such elements is straightforward. Let’s define a SwiftUIView and use the following code: import SwiftUI struct PageSliderView: View { // the data we want to present in each page, // this can be as simple as an array of string or as complex as an array of compound views.
Read more

Swift copy-on-write

To understand what copy-on-write means we need to delve into Swift’s type classification. Objects in Swift can be divided into two type groups: value types and reference types. The main difference between the two is how they are managed in memory. Theoretically, Value types create a new copy on memory each time they are assigned to a new variable, conversely reference types share the same reference amongst all variables. What is copy-on-write?
Read more

How to Create Databases Using Docker

The other day, I needed to set up a PostgreSQL database, and after considering various solutions, I decided to use Docker. In this tutorial, I’ll share the solution that worked for my problem. Creating a PostgreSQL Database Using Docker Compose Docker Compose is a powerful tool that allows us to manage multiple containers from a single central point. You might think it’s a bit much for setting up a database, but I found it surprisingly easy to set up and use.
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

Hello World

Hey there, tech enthusiasts! 📱, this is my first time blogging 🥳. I decided to create this blog to register all of my learning in the world of programming. I’m so exited to share what I’m learning in this cool journey. I’m bad for making intros, so if something new comes to my mind I’ll update this post. 😅 While my main focus right now is iOS development, that doesn’t mean I’m not intrigued by the myriad of options technology has to offer.
Read more