Data Structures & Algorithms
Posts: 14
“Remove Nth Node From End of List” is a popular problem on the online platform Leetcode, which tests a programmer’s ability to manipulate linked lists. The problem statement is as follows: Given a linked list, remove the nth node from the end of list and return its head. A linked list is a data structure […]
The Sliding Window technique is a way of solving problems that involve data structures such as arrays and strings. It’s often used to make algorithms more efficient. Something we all could use. The technique starts off by creating a window that slides through the data, looking for specific patterns or solutions. It can be a […]
Finding the longest substring without repeating characters in a given string is a common problem in computer science. This problem can appear in many different contexts, such as finding the most efficient way to compress a string, or finding the maximum number of characters that can be used in a password. The solution to this […]
Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes p and q as the lowest node in T that has both p and q as descendants (where we allow a […]
In Leetcode 38: Count and Say, we are given a string of letters and we need to count how many times each letter appears and say it out loud. This problem can be solved in a few different ways, but we will code two different solutions here. First, we will solve it with JavaScript and […]
Given an integer array nums, find a subarray that has the largest product, and return the product. The test cases are generated so that the answer will fit in a 32-bit integer. Example 1: Input: nums = [2,3,-2,4] Output: 6 Explanation: [2,3] has the largest product 6. Explanation: Given an array nums of integers, find […]
From Leetcode. 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 single digit. Add the two numbers and return the sum as a linked list. You may assume the two numbers do not contain any leading zero, except the number […]
Given the root of a binary tree, return the inorder traversal of its nodes’ values. The inorder traversal of a binary tree is the nodes in the tree listed in the order they would be visited by an inorder traversal. To solve this problem, we can use a stack to keep track of the nodes […]
From Leetcode: Given the root of a binary tree, return the level order traversal of its nodes’ values. (i.e., from left to right, level by level). What is being asked? The questions seems to be pretty straight forward. Given a binary tree, return the level order traversal of its nodes’ values. (ie, from left to […]
Question from Leetcode. A permutation of an array of integers is an arrangement of its members into a sequence or linear order. The next permutation of an array of integers is the next lexicographically greater permutation of its integer. More formally, if all the permutations of the array are sorted in one container according to […]