brain

tamnd's digital brain — notes, problems, research

42650 notes

LeetCode 1209 - Remove All Adjacent Duplicates in String II

The problem asks us to repeatedly remove groups of exactly k adjacent identical characters from a string until no more such groups exist. A removal operation works as follows: - Find k consecutive characters that are all the same. - Remove those characters from the string.

leetcodemediumstringstack
LeetCode 952 - Largest Component Size by Common Factor

The problem asks us to find the largest connected component in a graph derived from an array of unique positive integers nums.

leetcodehardarrayhash-tablemathunion-findnumber-theory
LeetCode 1004 - Max Consecutive Ones III

This problem asks us to find the length of the longest contiguous subarray that can contain only 1s after flipping at most k zeroes into ones.

leetcodemediumarraybinary-searchsliding-windowprefix-sum
LeetCode 1274 - Number of Ships in a Rectangle

The problem presents an interactive scenario where ships are placed at integer coordinates on a Cartesian plane. You do

leetcodehardarraydivide-and-conquerinteractive
CF 41E - 3-cycles

We need to build an undirected graph on n cities such that no triangle exists. A triangle means three distinct cities where every pair is directly connected.

codeforcescompetitive-programmingconstructive-algorithmsgraphsgreedy
CF 103E - Buying Sets

We are given several sets of integers, each with an associated cost. We may choose any collection of these sets, including the empty collection. Let the number of chosen sets be $k$, and let the union of all chosen sets contain $u$ distinct integers.

codeforcescompetitive-programmingflowsgraph-matchings
LeetCode 181 - Employees Earning More Than Their Managers

This problem gives us a single database table named Employee. Each row represents one employee and contains four pieces of information: Column Meaning --- --- id Unique identifier for the employee name Employee name salary Employee salary managerId The id of that employee's…

leetcodeeasydatabase
LeetCode 1650 - Lowest Common Ancestor of a Binary Tree III

This problem asks us to find the lowest common ancestor, usually abbreviated as LCA, of two nodes in a binary tree. Unli

leetcodemediumhash-tabletwo-pointerstreebinary-tree
CF 44E - Anfisa the Monkey

We are given a string of lowercase letters that contains no spaces. The task is to split this string into exactly k consecutive pieces. Every piece must have length between a and b, inclusive. The order of characters cannot change. We are only deciding where to cut the string.

codeforcescompetitive-programmingdp
LeetCode 1528 - Shuffle String

The problem asks us to take a string s and an integer array indices of the same length, and produce a new string where e

leetcodeeasyarraystring
LeetCode 49 - Group Anagrams

The problem asks us to group together all strings that are anagrams of each other. Two strings are considered anagrams if they contain exactly the same characters with the same frequencies, but possibly in a different order.

leetcodemediumarrayhash-tablestringsorting
LeetCode 1637 - Widest Vertical Area Between Two Points Containing No Points

This problem gives us a list of points on a 2D plane, where each point is represented as [x, y]. We need to find the widest vertical area that contains no points strictly inside it. A vertical area is defined by two vertical lines.

leetcodeeasyarraysorting
LeetCode 647 - Palindromic Substrings

The problem asks us to count how many palindromic substrings exist inside a given string s. A substring is any contiguous segment of the string. This means we cannot rearrange characters or skip positions.

leetcodemediumtwo-pointersstringdynamic-programming
LeetCode 1454 - Active Users

The problem asks us to identify active users from a database containing two tables: Accounts and Logins. The Accounts ta

leetcodemediumdatabase
LeetCode 361 - Bomb Enemy

The problem presents an m x n matrix called grid where each element is a character representing either a wall 'W', an enemy 'E', or an empty cell '0'. The task is to determine the maximum number of enemies that can be eliminated by placing a single bomb in an empty cell.

leetcodemediumarraydynamic-programmingmatrix
LeetCode 602 - Friend Requests II: Who Has the Most Friends

The problem gives us a database table named RequestAccepted, where each row represents a successfully accepted friend request between two users. Every record contains a requesterid, an accepterid, and the date the request was accepted.

leetcodemediumdatabase
CF 62B - Tyndex.Brome

The task is to compute a kind of "distance" between a user-entered address and a list of potential addresses, according to a specific error function. The user enters a string s of length k. Then there are n potential addresses, each a string of arbitrary length.

codeforcescompetitive-programmingbinary-searchimplementation
LeetCode 1287 - Element Appearing More Than 25% In Sorted Array

The problem gives us a sorted integer array in non-decreasing order. We are guaranteed that exactly one element appears

leetcodeeasyarray
LeetCode 632 - Smallest Range Covering Elements from K Lists

The problem gives us k sorted integer lists, and we must find the smallest inclusive range [a, b] such that the range contains at least one element from every list. Each list is already sorted in non-decreasing order, which is a very important property.

leetcodehardarrayhash-tablegreedysliding-windowsortingheap-(priority-queue)
CF 68B - Energy exchange

We have several accumulators, each storing some amount of energy. We are allowed to move energy between them, but every transfer wastes a fixed percentage. If we send x units from one accumulator, the sender loses all x, while the receiver only gains x (100 - k) / 100.

codeforcescompetitive-programmingbinary-search
LeetCode 850 - Rectangle Area II

This problem asks us to compute the total area covered by a set of axis-aligned rectangles on a 2D plane. Each rectangle is defined by its bottom-left and top-right coordinates [xi1, yi1, xi2, yi2].

leetcodehardarraysegment-treesweep-lineordered-set
LeetCode 1309 - Decrypt String from Alphabet to Integer Mapping

The problem gives us a string containing digits and the '' character. This string encodes lowercase English letters usin

leetcodeeasystring
LeetCode 2005 - Subtree Removal Game with Fibonacci Tree

The problem defines a special kind of binary tree called a Fibonacci tree. The structure is recursive: - order(0) is an empty tree. - order(1) is a single node. - order(n) has: - a root node, - a left subtree equal to order(n - 2), - a right subtree equal to order(n - 1).

leetcodehardmathdynamic-programmingtreebinary-treegame-theory
LeetCode 65 - Valid Number

This is a comprehensive, multi section technical guide that will be quite long if completed properly with all requested sections, detailed explanations, two implementations, walkthroughs, worked examples, complexity analysis, exhaustive test cases, and edge case discussions.

leetcodehardstring
LeetCode 1456 - Maximum Number of Vowels in a Substring of Given Length

This problem asks us to determine the maximum number of vowels that appear in any substring of a given length k within a

leetcodemediumstringsliding-window
LeetCode 1132 - Reported Posts II

The problem asks us to calculate the average daily percentage of posts that were removed after being reported as spam. We are given two tables: Actions and Removals.

leetcodemediumdatabase
LeetCode 161 - One Edit Distance

The problem asks us to determine whether two strings are exactly one edit apart. An edit can be one of three operations: 1. Insert a single character 2. Delete a single character 3. Replace one character with a different character The key detail is the word exactly.

leetcodemediumtwo-pointersstring
LeetCode 709 - To Lower Case

The problem asks us to convert every uppercase English letter in a string into its lowercase equivalent. Any character that is already lowercase, or is not an alphabetic character at all, should remain unchanged. The input is a string s containing printable ASCII characters.

leetcodeeasystring
CF 45G - Prime Problem

We have houses numbered from 1 to n. Every house must receive a color. For each color, if we add together all house indices painted with that color, the result must be a prime number.

codeforcescompetitive-programmingnumber-theory
LeetCode 579 - Find Cumulative Salary of an Employee

This problem asks us to compute a cumulative salary summary for each employee based on their monthly salaries over the year 2020. The input is a table Employee where each row contains an employee id, the month (1 through 12), and the salary for that month.

leetcodeharddatabase
CF 65B - Harry Potter and the History of Magic

We are given a sequence of four-digit years. Each year may contain mistakes, but we are allowed to repair it by changing at most one digit. After all repairs, the sequence must become non-decreasing, and every resulting year must stay between 1000 and 2011 inclusive.

codeforcescompetitive-programmingbrute-forcegreedyimplementation
LeetCode 122 - Best Time to Buy and Sell Stock II

This problem asks us to maximize profit from stock trading over a sequence of days. We are given an array prices, where prices[i] represents the stock price on the ith day.

leetcodemediumarraydynamic-programminggreedy
CF 39I - Tram

We are given a directed graph where nodes represent crossroads and edges represent one-way tramlines. The engine house is at node 1. Every node has at least one outgoing edge, so the tram is never trapped.

codeforcescompetitive-programming
LeetCode 1347 - Minimum Number of Steps to Make Two Strings Anagram

This problem asks us to determine the minimum number of character replacements needed to transform string t into an anagram of string s. Two strings are anagrams if they contain exactly the same characters with the same frequencies, regardless of order.

leetcodemediumhash-tablestringcounting
LeetCode 469 - Convex Polygon

The problem gives us a sequence of points on a 2D plane. These points are connected in order, and the final point connects back to the first point, forming a polygon. Our task is to determine whether that polygon is convex.

leetcodemediumarraymathgeometry
LeetCode 415 - Add Strings

The problem asks us to add two non-negative integers where each integer is given as a string instead of a numeric type. The goal is to return the resulting sum as another string. For example, if the inputs are "11" and "123", we should return "134".

leetcodeeasymathstringsimulation
LeetCode 1107 - New Users Daily Count

We are given a database table called Traffic that records different user activities on different dates. Each row contains a userid, an activity type, and an activitydate.

leetcodemediumdatabase
CF 34D - Road Map

We are given a tree with n cities. Originally, city r1 is considered the capital, and for every other city we know its parent in the rooted tree. The value p[i] means that if we walk from the old capital toward city i, the last city before reaching i is p[i].

codeforcescompetitive-programmingdfs-and-similargraphs
LeetCode 1719 - Number Of Ways To Reconstruct A Tree

The problem provides an array of pairs, where each pair [xi, yi] indicates that xi is either an ancestor of yi or yi is an ancestor of xi in a rooted tree. The key challenge is to determine how many different rooted trees satisfy all given pairs.

leetcodehardarrayhash-tabletreegraph-theorysimulation
CF 49B - Sum

We are given two integers, _a_ and _b_, written in some unknown base _p_. Vasya wants to compute the sum _a + b_ in all valid bases and determine which base gives the sum with the largest number of digits.

codeforcescompetitive-programmingmath
CF 89B - Widget Library

We are asked to simulate a tiny GUI layout system. There are three kinds of widgets. A plain Widget has a fixed width and height. HBox and VBox are container widgets that can store other widgets. An HBox places children horizontally, while a VBox places them vertically.

codeforcescompetitive-programmingdpexpression-parsinggraphsimplementation
LeetCode 1144 - Decrease Elements To Make Array Zigzag

The problem gives an integer array nums and allows only one type of operation, decreasing any element by 1. We may perform this operation as many times as needed on any elements. Our goal is to transform the array into a zigzag array with the minimum number of moves.

leetcodemediumarraygreedy
LeetCode 310 - Minimum Height Trees

This problem gives us an undirected tree with n nodes labeled from 0 to n - 1. The input edges describes the connections between nodes, and because the graph is guaranteed to be a tree, several important properties immediately hold true.

leetcodemediumdepth-first-searchbreadth-first-searchgraph-theorytopological-sort
LeetCode 965 - Univalued Binary Tree

The problem gives us the root node of a binary tree and asks whether the tree is "uni-valued". A binary tree is considered uni-valued if every node in the tree contains exactly the same integer value.

leetcodeeasytreedepth-first-searchbreadth-first-searchbinary-tree
LeetCode 235 - Lowest Common Ancestor of a Binary Search Tree

The problem asks us to find the Lowest Common Ancestor, commonly abbreviated as LCA, of two nodes in a Binary Search Tree (BST). A lowest common ancestor of two nodes p and q is the deepest node in the tree that has both p and q as descendants.

leetcodemediumtreedepth-first-searchbinary-search-treebinary-tree
LeetCode 948 - Bag of Tokens

The problem gives us a collection of tokens, where each token has a numeric value. We also start with an initial amount of power and an initial score of 0. Every token can be used at most once, and each token can be played in exactly one of two ways.

leetcodemediumarraytwo-pointersgreedysorting
LeetCode 1769 - Minimum Number of Operations to Move All Balls to Each Box

This problem asks us to compute the minimum number of moves required to gather all balls in a string of boxes into each individual box. Each box can either be empty ('0') or contain one ball ('1'). A single operation consists of moving a ball from one box to an adjacent box.

leetcodemediumarraystringprefix-sum
LeetCode 471 - Encode String with Shortest Length

Here’s a fully detailed technical solution guide following your requested format for LeetCode 471 - Encode String with Shortest Length.

leetcodehardstringdynamic-programming
LeetCode 1544 - Make The String Great

The problem asks us to process a string s consisting of lowercase and uppercase English letters, removing pairs of adjac

leetcodeeasystringstack
LeetCode 111 - Minimum Depth of Binary Tree

The problem asks us to determine the minimum depth of a binary tree. In other words, given the root of a binary tree, we want to find the shortest path from the root node down to the nearest leaf node.

leetcodeeasytreedepth-first-searchbreadth-first-searchbinary-tree
CF 44G - Shooting Gallery

The problem can be restated as simulating bullets flying along the positive _Z_ axis at given coordinates on a 2D shooting plane (_XOY_). Each bullet may hit one of multiple rectangular targets floating at distinct heights along the _Z_ axis.

codeforcescompetitive-programmingdata-structuresimplementation
CF 56D - Changing a String

We are given two uppercase strings, s and t. We may transform s using three operations: 1. Insert a character at any position. 2. Delete a character from any position. 3. Replace one character with another. Every operation costs exactly one move.

codeforcescompetitive-programmingdp
CF 66B - Petya and Countryside

We have a garden represented as a one-dimensional array of sections, each with a fixed height. Petya can create artificial rain above exactly one section, and water will flow to neighboring sections as long as their height is less than or equal to the section the water comes…

codeforcescompetitive-programmingbrute-forceimplementation
LeetCode 1166 - Design File System

This problem asks us to design a simplified file system that supports two operations: 1. Creating a new path with an associated integer value. 2. Retrieving the value stored at a path. A path behaves similarly to a directory structure in a real operating system.

leetcodemediumhash-tablestringdesigntrie
LeetCode 171 - Excel Sheet Column Number

This problem asks us to convert an Excel-style column title into its corresponding numerical index. In Excel spreadsheets, columns are labeled alphabetically: The labeling system works similarly to a positional number system, except instead of digits 0-9, it uses letters A-Z…

leetcodeeasymathstring
LeetCode 741 - Cherry Pickup

This problem asks us to collect the maximum possible number of cherries while making two trips across a square grid. The first trip starts at the top left corner (0, 0) and moves to the bottom right corner (n - 1, n - 1) using only right or down moves.

leetcodehardarraydynamic-programmingmatrix
LeetCode 1831 - Maximum Transaction Each Day

The problem gives us a table named Transactions where each row represents a financial transaction. Every transaction has a unique transactionid, a timestamp stored in the day column, and an integer amount.

leetcodemediumdatabase
CF 130B - Gnikool Ssalg

The problem asks us to reverse a string. Given a sequence of characters, the output should be the same sequence but in the opposite order, so that the first character becomes the last, the second becomes the second-to-last, and so on.

codeforcescompetitive-programming*specialimplementationstrings
LeetCode 1657 - Determine if Two Strings Are Close

The problem asks whether two strings, word1 and word2, are "close" according to two allowed operations. Operation 1 allows swapping any two existing characters in the string, which means the relative order of characters is flexible.

leetcodemediumhash-tablestringsortingcounting
CF 49C - Disposition

We need to build a permutation of numbers from 1 to n. Position j contains volume p(j). A positive integer i is called a divisor of the disposition if there exists some position j such that both j and p(j) are divisible by i.

codeforcescompetitive-programmingconstructive-algorithmsmath
LeetCode 33 - Search in Rotated Sorted Array

The problem gives us an array that was originally sorted in ascending order, but may have been rotated at some pivot point. A rotation means that some prefix of the sorted array was moved to the end while preserving the relative order of elements.

leetcodemediumarraybinary-search
LeetCode 1153 - String Transforms Into Another String

The problem gives us two strings, str1 and str2, which are guaranteed to have the same length. We want to determine whether it is possible to transform str1 into str2 using a sequence of character conversion operations.

leetcodehardhash-tablestringgraph-theory
LeetCode 936 - Stamping The Sequence

This problem asks us to reconstruct a target string by repeatedly applying a smaller string called stamp. We begin with a string s that has the same length as target, but every character is initially '?'.

leetcodehardstringstackgreedyqueue
LeetCode 1195 - Fizz Buzz Multithreaded

The problem asks us to coordinate four separate threads so they collectively print the correct Fizz Buzz sequence in order from 1 to n. Unlike the classic single threaded Fizz Buzz problem, this version introduces concurrency.

leetcodemediumconcurrency
CF 2B - The least round way

We have an n × n grid of non-negative integers. Starting from the top-left corner, we may move only right or down until we reach the bottom-right corner. Along a chosen path, we multiply every visited value together.

codeforcescompetitive-programmingdpmath
LeetCode 1551 - Minimum Operations to Make Array Equal

The problem presents an array arr of length n where each element is defined by the formula arr[i] = 2 i + 1. This genera

leetcodemediummath
LeetCode 188 - Best Time to Buy and Sell Stock IV

This problem asks us to maximize the profit from stock trading under a strict constraint: we can perform at most k transactions, where each transaction consists of buying and then later selling one share of the stock.

leetcodehardarraydynamic-programming
LeetCode 1508 - Range Sum of Sorted Subarray Sums

The problem requires calculating the sum of a subrange of all possible contiguous subarray sums of a given array nums.

leetcodemediumarraytwo-pointersbinary-searchsortingprefix-sum
CF 87B - Vasya and Types

The language in this problem has only two real base types, void and errtype. Every other type is defined through typedef, and every query asks us to evaluate a type expression with typeof. A type expression is built from a base name plus some number of and & operators.

codeforcescompetitive-programmingimplementationstrings
LeetCode 2016 - Maximum Difference Between Increasing Elements

The problem is asking us to find the maximum difference between two elements in an array, with the condition that the smaller element appears before the larger element.

leetcodeeasyarray
LeetCode 1165 - Single-Row Keyboard

The problem describes a single-row keyboard where each key is positioned at a unique index from 0 to 25. You are given a string keyboard of length 26 that specifies the layout of all lowercase English letters.

leetcodeeasyhash-tablestring
CF 14C - Four Segments

We are given exactly four line segments on the 2D plane. Every segment is axis-aligned, or may even degenerate into a single point.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgeometryimplementationmath
LeetCode 1778 - Shortest Path in a Hidden Grid

This problem asks us to find the shortest path from a robot's unknown starting position to a hidden target inside a grid. The major challenge is that the grid itself is not directly accessible.

leetcodemediumarraydepth-first-searchbreadth-first-searchmatrixinteractive
CF 75C - Modified GCD

We are given two positive integers, and then many range queries. For each query [low, high], we must find the largest integer inside that interval that divides both numbers. The first observation is that we are not really working with a and b independently.

codeforcescompetitive-programmingbinary-searchnumber-theory
LeetCode 1363 - Largest Multiple of Three

I can do that, but the guide will be very long and may get truncated in a single message because of the required depth a

leetcodehardarraymathdynamic-programminggreedysorting
CF 106E - Space Rescuers

We are asked to place a space rescue station in three-dimensional space such that the maximum distance from it to any of the given planets is minimized. Each planet is represented by its coordinates $(x, y, z)$.

codeforcescompetitive-programminggeometryternary-search
LeetCode 1406 - Stone Game III

In this game, two players, Alice and Bob, take turns removing stones from the beginning of a row. Each stone has an inte

leetcodehardarraymathdynamic-programminggame-theory
LeetCode 136 - Single Number

The problem gives an integer array nums where every value appears exactly twice except for one value that appears only once. The task is to find and return that unique value.

leetcodeeasyarraybit-manipulation
CF 61B - Hard Work

We are given three original strings. A student's answer is considered correct if it can be formed by concatenating these three strings in any order, after ignoring two kinds of differences. The first difference is letter casing.

codeforcescompetitive-programmingstrings
CF 17E - Palisection

We are given a string and we consider every palindromic substring inside it. Each occurrence matters separately, even if two substrings have the same text. For example, in "aaa" there are three different occurrences of "a".

codeforcescompetitive-programmingstrings
CF 22B - Bargaining Table

The office floor is represented as an n × m grid. Each cell is either free, written as 0, or blocked by furniture, written as 1. We want to place one rectangular table whose sides stay aligned with the grid. Every cell covered by the rectangle must be free.

codeforcescompetitive-programmingbrute-forcedp
CF 51F - Caterpillar

We start with an undirected graph that may be disconnected and may contain cycles. We are allowed to repeatedly merge two vertices into one. Merging decreases the number of vertices by one, while the number of edges stays unchanged.

codeforcescompetitive-programmingdfs-and-similardpgraphstrees
LeetCode 830 - Positions of Large Groups

The problem asks us to identify all large groups in a given string and return their positions as intervals. A group is a sequence of consecutive identical characters.

leetcodeeasystring
CF 18A - Triangle

We are given three points on the plane with integer coordinates. These three points already form a valid triangle, meaning they are not collinear.

codeforcescompetitive-programmingbrute-forcegeometry
LeetCode 322 - Coin Change

The problem gives us an array called coins, where each element represents a coin denomination, and an integer called amount, which represents the target sum we want to construct. Our goal is to determine the minimum number of coins needed to make exactly amount.

leetcodemediumarraydynamic-programmingbreadth-first-search
CF 132A - Turing Tape

We are given the final text printed by INTERCAL's strange "Turing Tape" output procedure. Each printed character was produced from one integer of an unknown array. The encoding process depends on the previous printed character, so every step is linked to the one before it.

codeforcescompetitive-programmingimplementation
LeetCode 1676 - Lowest Common Ancestor of a Binary Tree IV

This problem asks us to find the Lowest Common Ancestor, or LCA, of multiple nodes in a binary tree. Unlike the classic

leetcodemediumhash-tabletreedepth-first-searchbinary-tree
LeetCode 552 - Student Attendance Record II

The problem asks us to count how many attendance records of length n satisfy two award eligibility rules. Each attendance record is a string made up of three possible characters: - 'P' means the student was present. - 'A' means the student was absent.

leetcodeharddynamic-programming
LeetCode 838 - Push Dominoes

This problem models a chain reaction of falling dominoes. We are given a string where each character represents the initial state of a domino in a row. A domino can be in one of three states: - 'L' means the domino has been pushed to the left.

leetcodemediumtwo-pointersstringdynamic-programming
CF 74D - Hanger

We have a single row of hooks, numbered from 1 to n, which initially are all empty. Employees arrive and leave at specified times, and each arrival or departure is encoded by an employee ID: the first occurrence is an arrival, the second is the departure, and so on.

codeforcescompetitive-programmingdata-structures
LeetCode 1258 - Synonymous Sentences

This problem asks us to generate all possible synonymous variations of a given sentence based on a list of equivalent wo

leetcodemediumarrayhash-tablestringbacktrackingsortunion-find
LeetCode 412 - Fizz Buzz

The problem asks us to generate a list of strings for all integers from 1 to n. For each number, we apply a set of divisibility rules: - If the number is divisible by both 3 and 5, we append "FizzBuzz". - If the number is divisible only by 3, we append "Fizz".

leetcodeeasymathstringsimulation
CF 60E - Mushroom Gnomes

We are given a line of mushrooms, each with a weight, initially sorted in non-decreasing order. Every minute, new mushrooms grow between every pair of neighboring mushrooms, and the weight of each new mushroom equals the sum of the two neighboring mushrooms.

codeforcescompetitive-programmingmathmatrices
LeetCode 757 - Set Intersection Size At Least Two

The problem asks us to find the minimum size of a set of integers, nums, such that each given interval [starti, endi] contains at least two integers from nums.

leetcodehardarraygreedysorting
LeetCode 1695 - Maximum Erasure Value

This problem asks us to find a contiguous subarray that contains only unique elements, meaning no value appears more than once inside that subarray. Among all such valid subarrays, we must return the maximum possible sum of its elements.

leetcodemediumarrayhash-tablesliding-window
LeetCode 1205 - Monthly Transactions II

This problem asks us to generate a monthly financial summary for each country using information from two database tables: Transactions and Chargebacks. The Transactions table stores incoming transactions.

leetcodemediumdatabase
CF 7D - Palindrome Degree

We are given a string consisting of letters and digits, and we are asked to compute a special measure for every prefix called the _palindrome degree_.

codeforcescompetitive-programminghashingstrings
CF 33E - Helper

Valera has a list of subjects he knows how to solve. Every subject takes a fixed amount of working time. Students come with requests: each request has a subject, an exam deadline, and a reward. If Valera finishes the solution strictly before the exam starts, he gets paid.

codeforcescompetitive-programming
CF 20B - Equation

We are asked to solve a quadratic equation of the form , where , , and are integers in the range . The goal is to find all real roots of the equation, count them, and print them in ascending order with high precision.

codeforcescompetitive-programmingmath
LeetCode 753 - Cracking the Safe

This problem asks us to generate the shortest possible string that guarantees a safe will unlock at some point while typing it. The safe password has exactly n digits, and each digit can be any value from 0 to k - 1. The safe does not validate the entire entered sequence at once.

leetcodehardstringdepth-first-searchgraph-theoryeulerian-circuit