In this article I’ll be going over the leetcode question length of last word. In this problem the main topic it will cover are strings. Here’s the breakdown of the problem.
Given a string s consists of some words separated by spaces, return the length of the last word in the string. If the last word does not exist, return 0.A word is a maximal substring consisting of non-space characters only.Example 1:Input: s = "Hello World"
Output: 5Example 2:Input: s = " "
So looking at this problem it says that the words…
CSV stands for comma separated values which is commonly seen in excel spreadsheets. While on a program like excel the data will appear with columns and rows inside its own cells, once viewed as raw code the CSV file will look something like this.
"name, age, gender"
"Bill, 24, male"
"Ana, 20, female"
Ruby has a built in library that allows us to do many things with CSV files. To begin go ahead and create a new file and add
at the top. Now that you can use an entire set of methods to do what you’d like…
Test driven development (TDD) allows developers to ensure that they’re on the right track in their development roadmap. In this article I’ll go over some basic Rspec tests that can be used for your controllers in your Rails API. Before we start add the ‘rspec-rails’ gem to your gemfile. The run
in your terminal to install it. Now you go ahead and run
rails generate rspec:install
This will then create a spec directory and a .rspec file. From here we can create our tests that we’ll run. It’s important to note that the tests you will run in your…
A package manager or package management system is a collection of software tools that automates the process of installing, upgrading, configuring, and removing software packages for a computer’s operating system in a consistent manner. It typically maintains a database of software dependencies and version information to prevent software mismatches and missing prerequisites.
Above is a definition of a package manager from Wikipedia. Let’s quickly break it down to better understand what we’re working with. A package is a reusable piece of software that you can download from another source into your local environment. Now a package manager will…
The React Native FlatList is a very useful component for rendering a refined list of all your data that you are trying to display. It’s most commonly used when displaying a list of contacts or news article headlines. A basic overview of how the components are rendered is that one file will fetch your data and pass it down to your components as a prop. From there the component that receives that props uses them to render your desired data onto your components. Let’s walk through a quick example building out a flatlist that renders some news articles.
The REST architectural style has been the standard for designing APIs for quite some time. One main critique of REST is that it can be inflexible at times. GraphQL enters the situation as an alternative to the mainstream and it even offers a more flexible and efficient solution than REST for fetching your data.
Let’s say for example we were attempting to fetch some data for a user. In some cases we’d find ourselves using multiple endpoints to gather the users information such as its posts and followers. Whereas with GraphQL you would simply send one Query and you’d get…
Cryptocurrencies are leading the charge for a decentralized world. They’re known for being protected from inflation, secure, and unfortunately extremely volatile. However, with the introduction of stablecoins there are ways to mitigate this issue.
Investopedia’s definition of stablecoins is that they’re a new class of cryptocurrencies that attempts to offer price stability and are backed by a reserve asset. Stablecoins have gained traction as they attempt to offer the best of both worlds — the instant processing and security or privacy of payments of cryptocurrencies, and the volatility-free stable valuations of fiat currencies. Tether is known as one of the…
Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays.
So for example if we were given the following inputs we should get an output that displays the median.
Input: nums1 = [1,3], nums2 = 
To get to our solution the first thing I’d do is merge the two arrays. Once the arrays have been…
Before building your API make sure you have Node.js and MongoDB installed and setup on your machine before starting this tutorial. The complete code can be found here.
Let’s get started by first opening up our terminal and creating a folder for our API. I chose to name my folder node-practice but feel free to name it whatever you’d like.
Then cd into your folder and open it in your text editor. I’ll be using VSCode for this tutorial. Next initialize the package.json file.
npm init -y
Your package.json file will now look like this.