Search Results


13 matches found for 'cycle'

Detecting a cycle in a linked list

Problem Detect a cycle in a linked list and return the node that represents the start of the cycle. Input head: a pointer to the linked list Approach First, lets concentrate on how to detect a cycle in a linked list.


Algorithm Handbook

... pointer will be at the \(k\) th item from the end of the list. Cycle: Detect a cycle by incrementing the fast pointer by 2 and slow pointer by 1. Eventually the two will meet.


Rotate a 2D Matrix

... the leftmost, topmost, rightmost, and bottommost values. This could be labeled as the outermost cycle. Once this cycle is complete, we will have to start swapping again for the next innermost cycle.


Search in a rotated sorted array

... index, the highest index, and using the two indices you can determine the middle index. The cycle (where the smallest number is right after the largest number) can only exist in one half of the array: either the left-half, or the right-half.


Cyclic Permutation

... value in P as an index to A) One interesting thing about these indices is that it represents a cycle. Using the original example from above: A = ['a', 'b', 'c', 'd'] P = [1, 3, 2, 0] Then we first look at A[0] and P[0].


Find the duplicate number

... is a duplicate since \(i = A[i]\), so we return \(i\). Fun fact: This is similar to detecting a cycle in a linked list. If you treat the integer values of the array as pointers, then running into the same pointer value implies that a cycle exists.


Working with Production at Amazon Retail Website

... the way. Lesson 1: Pipelines A good CI/CD (continuous integration / continuous development) cycle can be visualized with pipelines. At its most basic level, a pipeline serves as the workflow from changes that have been committed (i.


Web Development 101

... called Components. The unique thing about these components is that they have a state life-cycle, allowing for some creative and dynamic views. This means that if your components change over time (for example, a ticking timer text box) , React allows you to handle those changes in a convenient, easy way.


4 Line Depth-first Search

... the neighbors of some given vertex. Topological Sort Topological sort is a directed acyclic (no cycles) graph ordering that sorts based on the property that u comes before v when there is a directed edge from u that points to v.


Topological Sorting

... is complete, and we add 1 to the total count. Repeat #3 until all nodes are explored. If a cycle is present, then some node N-degree counts will never reach all the way down to 0, resulting in total being less than the number of vertices in the entire graph.


Algorithm Interview Problems

Welcome This page contains solutions to common interview problems that may be encountered. Arrays Longest Substring Without Repeating Characters Rotate a 2D Matrix Buy/Sell Two Stocks Merge Intervals Next Permutation Random Permutation Replace all occurrences of a space with a string Linked Lists Reversing sublists of singly linked lists Cycles in singly linked lists Overlapping singly linked lists Merging two sorted singly linked lists Merge k sorted lists Recursion Counting the path of sums Money Denominations Phone Number Mnemonics Unique Permutation Dynamic Programming Perfect Squares Find the Maximum Min Path Binary Trees Tree Symmetry Iterative In-Order Traversal of a Binary Tree Construct a Binary Tree from Pre-Order Traversal and In-Order Traversal BST Validate a BST Binary Heaps Merge k sorted lists Graphs Find a path in a maze from start to finish Flip colors in a matrix Search Search in a rotated sorted array Find the Duplicate Number Greedy Algorithms Queue Reconstruction By Height Trie Build a Trie in Python Invariant Compute the max.


Design Concepts

In this article, I want to go over some fundamental design concepts that are useful for coming up with system design. Requirements Functional Requirements Describes specific behaviors i.e. If a URL is generated, it is composed of a Base64 encoded alias Non-functional Requirements Describes architectural requirements i.


Software Methodologies

... in a nutshell is basically a set of principles laid out to promote fast and efficient development cycles. Scrum Scrum is an Agile methodology, so it attempts to cover the Agile principles by bringing in processes and rules to help facilitate them.