Dashing through Leetcode problems, I found this one: Linked List Cycle. In this blog, I’ll solve it using the two-pointer approach.
Our task is to determine if the linked list has a cycle in it. Return true if there is a cycle in the linked list. Otherwise, return false.
What is considered to be a cycle? There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the next pointer. Have a look at this example.
While working on group projects, it is truly vital to organize your workflow consistently and productively. You can use a spreadsheet, which works well for smaller projects. But what if you’re building something more complicated, with a bigger team involved? You can definitely use a database, but it might be too time-consuming and also require some SQL knowledge.
That’s where project planners and organizers come into play.
The market offers tons of different options. For our current project, my partner suggested that we use Airtable and I found this one pretty intuitive and easy to implement.
Airtable is a cloud-based software company that combines a traditional spreadsheet with a database. Wikipedia mentions that the fields in an Airtable table are similar to cells in a spreadsheet, but have types such as ‘checkbox’, ‘phone number’, and ‘drop-down list’, and can reference file attachments like images. Also, a user can create a database, set up columns and records — and collaborate with other users, which makes it really helpful for group projects. …
Recently, while working my way through this tutorial, I came across a React library called prop-types. I’ve never used this library before, so I made a quick research on why we need prop-types and how to use is.
JavaScript is a so-called “untyped” language. That means JavaScript will figure out what type of data you have and make a function work without any required adjustments. For example, it can convert a number into a string if it is what a function expects. Sound great, right? However, it can be a blessing until it turns into a curse.
As your app grows, this JavaScript feature can lead to bugs and errors when the data type we expected is not the one we’ve passed. So, to check that data type seems like a smart decision. That’s where React built-in type checking ability comes into play. PropTypes
is a library that helps to check whether the props you pass have the type you’re waiting for. …
I think we all can agree on this: Two-Sum Algorithm is sort of a classic data structure challenge. In my blog, I’d like to share two approaches to solving it. The first one is a so-called “brute force” method, and the second one represents a more elegant solution
So, our problem is: Given an array of numbers and a target number, find the sum of two numbers from the array that is equal to the target number. May not sum the same index twice. Return these numbers.
Here, I’m using nested for-loops to check all possible sums in the array. Once I get the right pair, I return them. If nothing matches, an empty array is returned. …
Solving a palindrome algorithm is one of the most common data structure tasks during a technical interview. In this blog, I’m going to break down one of those algorithms and share with you my method of solving it. It might be not the smartest and the most efficient way, so feel free to come up with any other!
First things first: what is a palindrome? It is a sequence of characters that reads the same backward or forward. Our task is to find out whether a given string is a palindrome. Return true if the given string is a palindrome. …
Sometimes, while studying more sophisticated concepts, we tend to forget some basic methods and approaches. so, this week I was revising some of the most commonly used array methods in JavaScript. In this short blog, I’ll show you the difference between some() and every() methods that are often confused between each other.
The MDN documentation says that:
Sounds like a challenge, right?
Well, it is actually a challenge that I’ve recently taken! Here is the link: #JavaScript30.
It’s a 30-day vanilla JS coding challenge. During these 30 days (more or less — you can binge the tutorials Netflix style to take it as slow as you like because you’ll get an instant and free access to all the videos) you’ll build 30 different apps using fun and easy video tutorials. You don’t need any frameworks or libraries — it’s just about basic HTML, CSS and vanilla Javascript.
While following the instructions in tutorials, you’ll feel more and more comfortable with the DOM manipulations and pure JS. That’s true, frameworks make our lives as developers a lot easier but I strongly believe that one should always have a clear understanding of the basics and of how a language really works without these frameworks “crutches”. These tutorials rely upon browser APIs, which makes it easy to test and debug. You’ll learn while you build and encounter different situations and problems. …
I believe that a graph is probably one of the most complicated data structures. One can say, it even looks confusing (check the picture at the top!), with all these messy elements aka nodes and lines. Ironically, this is one of the most commonly used data structures in the real world.
Where can we meet these mysterious graphs? Well, almost everywhere. Here are some vivid examples you’ve more than definitely encountered.
Unlike arrays and linked lists, a tree is a non-linear data structure that connects nodes (or, elements) in a parent-child relationship. That means the data is organized hierarchically. Each parent node has a pointer to a child node and therefore knows about it.
Another important feature of trees is the fact that they are a recursive data structure — same as arrays and linked lists! In other words, each tree is made up of other trees with parent and child nodes.
When we look at a tree, we can clearly see that it resembles a family tree or an organization hierarchy. Another example that comes to my mind is React. If you’re familiar with this framework, you definitely know that the components have pretty much the same hierarchy as a tree data structure. …
What is actually a linked list?
Well, first of all, it’s a very common and broadly used type of data structure. According to Wikipedia, a linked list is is a linear collection of data elements whose order is not given by their physical placement in memory. Instead, each element (or, node) points to the next, which alongside other nodes represents a sequence.
This scary-sounding “order is not given by their physical placement in memory” is a very important feature: that means, we can add and remove elements from the beginning less costly (think about time and space complexity!) than when we do so by implementing an array’s shift() and unshift() methods. …
About