#Csce 500 Design And Analysis Of Algorithms
Given a string s, rearrange the characters of s so that any two adjacent characters are not the same.Return any possible rearrangement of&nb
A sort that return a specific order of the vertex of a given a graph as long as the graph satisfies certain condition. This is a simple algorithm to learn.First
Arrays are where we start as devs. But what if I told you arrays secretly stack superpowers?Let's go beginner → expert: mastering arrays, stacks, monotonic stac
You are given an integer array nums of size n containing each element from 0 to n - 1 (inclusive). Each of the
🧠 Why Learn This?Matrix rotation isn't just a coding interview favorite It's used in AI, ML, and image processing to manipulate data efficiently.Think:Rotating
You are given an integer array nums. The range of a subarray of nums is the difference between the largest and smallest element in the
🔁 Problem Restatement (in simpler terms)You are given:A directed graph with n nodes.Each node i has a color, colors[i] ∈ {a-z}.Each path from one node to anoth
1️⃣ Understanding the ProblemThe Decode String problem asks us to decode a string like 3[a2[c]] into accaccaccFormat: k[encoded_st
The Problem:Given an integer array nums, you need to find one continuous subarray such that if you only sort this subarray in non-decreasing orde
🌍 The Why?Event Timeline Visibility:Think of mountains as tasks, events, or ads that want to be seen. Only those not completely covered by others are visible.U
🌊 The ProblemWe have a 2D map grid filled with '1's land and '0's water. An island is a group of connected '1's (horizontally or verti
Chapter 1: The Mysterious SlowdownAlex, a junior engineer at a fast-paced AI startup, was proud of their latest code. It processed massive datasets for a new re
Once upon a time, in a village of coders, there lived a gardener named Prashant. He had two ways of planting flowers in his garden Greedy and Non
🧠 Why Are You Learning This?The minimum-weight arborescence (MWA) problem is a fundamental problem in graph theory with applications in:Network desig
Let me walk you through the different variations of the LCA problem and how to solve each one with slight modifications to the core algorithm.1. Basic LCA Probl
Greedy algorithms:The class of algorithms that make locally optimal choices at each step with the hope that these choices will lead to a globally optimal soluti
You are given a non-negative integer array nums. In one operation, you must:Choose a positive integer x such that x is less than or equ
1. What Are We Talking About?The 132 pattern is a problem where we need to find a subsequence of three numbers in an array (nums[i], nums[j],&nbs
Situation:You are given a sorted array of integers where every element appears exactly twice, except for one element that appears only once.
In the world of computer science and mathematics, some problems are deceptively simple to describe but incredibly challenging to solve.One such problem is the&n
Greedy algorithm only applies to the optimization problem.Greedy algorithm makes the decision at every point choosing the local minimum or maximum depending on
Given the roots of two binary trees p and q, return true if the trees are equivalent, otherwise return false.Two binary trees
This problem check if a certain part of a tree is same tree as a given subtree.So before we solve this problem, we need to know how to check if two trees are sa
Binary search tree is great for searching or comparing things?We know using a hash-table we have O(1) for look up, then why study Binary Search Tree?Why is this
Given a binary tree, return true if it is height-balanced and false otherwise.A height-balanced binary tree is defined a