Algorithm / Leet Code Medium

[Swift] Optimal Partition of String

April 03 2023

Given a string s, partition the string into one or more substrings such that the characters in each substring are unique. That is, no letter appears in a sin...

[Swift] 4Sum

September 17 2022

Given an array nums of n integers, return an array of all the unique quadruplets [nums[a], nums[b], nums[c], nums[d]] such that:

[Swift] 3Sum Closest

September 16 2022

Given an integer array nums of length n and an integer target, find three integers in nums such that the sum is closest to target.

[Swift] Add Two Numbers

April 27 2022

You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a s...

[Swift] 3Sum

April 26 2022

Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0.

[Swift] String to Integer (atoi)

April 24 2022

Implement the myAtoi(string s) function, which converts a string to a 32-bit signed integer (similar to C/C++’s atoi function).

[Swift] Zigzag Conversion

April 15 2022

The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for bet...

[Swift] Merge Intervals

April 15 2022

Given an array of intervals where intervals[i] = [start$_i$, end$_i$], merge all overlapping intervals, and return an array of the non-overlapping intervals ...

[Swift] LRU Cache

October 20 2021

Design a data structure that follows the constraints of a Least Recently Used (LRU) cache.

[Swift] Next Permutation

August 20 2021

Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.