For the past few months, I’ve been working on an application that is responsible for processing in-memory data. The project is exciting to me for two reasons. One is that the project is written entirely in Rust, and the other is the opportunity to learn about new topics and libraries. This article explores what I have learned while working with Apache Arrow.

When I first started working on the project, I was not aware of Apache Arrow. I just needed a way to aggregate data as efficiently as possible. I even built a proof-of-concept that provided most of the functionality…


GraphQL is a very popular framework for developing client-facing APIs. This article covers the basics of integrating GraphQL with Rust including designing a code-first schema, setting up a GraphQL server, and implementing custom resolvers and mutations.

Why GraphQL and Rust

The idea for this article spawned from what I’ve been doing at work recently. I normally spend my time writing Rust code, but I’ve recently been working with GraphQL in a TypeScript environment. …


The CSV file format is a very common method for storing tabular data. This article covers the basics of reading and writing CSV files, (de)serializing CSV data using the Serde library, and wraps up with a sample data aggregation example.

Introduction

The idea for this article came about because I needed a fast and convenient way to work with CSV formatted data. One option was to write my own library, but I didn’t feel like that was a convenient solution. So, after a bit of research, I decided to use the csv crate authored by Andrew Gallant. …


Problem Statement

There are two sorted arrays nums1 and nums2 of size n and m respectively. Find the median of the two sorted arrays. You may assume nums1 and nums2 cannot both be empty.

Examples

Example 1

nums1 = [1, 3] nums2 = [2] The median is 2.0

Example 2

nums1 = [1, 2] nums2 = [3, 4] The median is (2 + 3)/2 = 2.5

Approach 1: Merge Arrays

Since both input arrays are already sorted, a naive solution would be to merge the arrays by iterating through each and inserting the items into a new array. Then calculate the median.

Algorithm

initialize i and j to 0
initialize length of new…


LeetCode Problems with Rust

Problem

Given a string, find the length of the longest sub-string without repeating characters.

Examples

Example 1

Input: "abcabcbb" 
Output: 3
Explanation: The answer is "abc", with the length of 3.

Example 2

Input: "bbbbb" 
Output: 1
Explanation: The answer is "b", with the length of 1.

Example 3

Input: "pwwkew" 
Output: 3
Explanation: The answer is "wke", with the length of 3. Note that the answer must be a sub-string, "pwke" is a sub-sequence and not a sub-string.

A note on Strings in Rust

One thing to note is that Rust does not implement traditional string indexing due to issues that come up with utf-8 encodings. There are a few approaches to get…


A sample project that uses Warp and Tokio to build a simple asynchronous API.

This tutorial introduces the Warp framework by building an asynchronous CRUD API. I wrote this with the following goals in mind:

  1. Become familiar with the Warp framework.
  2. Become more familiar with using async/await in Rust
  3. Get a better understanding of API design in Rust

Design

Before getting into any coding, I’ll sketch out the design of the API. This will help with determining the necessary endpoints, handler functions, and how to store data.

Routes

For this API, I only need two routes.

/customers 


Problem

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 contain a single digit. Add the two numbers and return it as a linked list.

You may assume the two numbers do not contain any leading zero, except the number 0 itself.

Examples

Input: (2 -> 4 -> 3) + (5 -> 6 -> 4) 
Output: 7 -> 0 -> 8
Explanation: 342 + 465 = 807.

Initial Setup

Before this problem can be solved we need to talk about the data structure. If you are already familiar with linked…


Problem

Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use the same element twice.

Examples

Given nums = [2, 7, 11, 15], target = 9, Because nums[0] + nums[1] = 2 + 7 = 9, return [0, 1].

Approach 1: Brute Force

The naive approach to solving this problem is to loop through each element x in nums and then loop through each element again to find if there is a value that equals target - x

Algorithm

for i…

Andrew Leverette

Software Developer | Rust Programming Enthusiast | AWS Fan | Algorithms Geek | Tech Writer Hobbyist

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