lunaris_engine library

Support for doing something awesome.

More dartdocs go here.

Classes

ActorCritic
ANN
AodvNode
AodvRouteEntry
Argon2
Argon2 key derivation function implementation
Arithmetic
AStarNode<T>
Represents a node in the A* search with its f-score (g + h)
AStarResult<T>
A* with path cost calculation
Authority
Awesome
Checks if you are awesome. Spoiler: you are.
BayesianOptimization
BFT
Byzantine Fault Tolerance (BFT) - generic broadcast model
BGPAlgorithm<T>
BGP Algorithm implementation with policy-based route selection
BGPPathAttributes
Represents BGP path attributes for route selection
BGPRouteEntry<T>
Represents a BGP route with path attributes and policy information
BGPRoutingTable<T>
Represents the BGP routing information base (RIB)
BinaryTreeNode<T>
BLS12381Curve
BLS12-381 curve parameters
BLSKeyPair
BLS key pair
BLSPublicKey
BLS public key structure
BLSSignature
BLS signature structure
BLSSignatures
BLS digital signature algorithm implementation
Bridge<T>
Represents a bridge (critical edge) in the graph
BurnEvent
CatBoostLikeRegressor
ChordNode
CNN
Compact CNN wrapper (ANN-backed)
Contact
DecisionTreeClassifier
Delegate
Dinic
DinicsEdge<T>
Represents a flow network edge with capacity and flow
DinicsResult<T>
Dinic's algorithm with detailed analysis and performance metrics
DisjointSet<T>
A generic implementation of the Disjoint Set (Union-Find) data structure with path compression and union by rank optimization.
DistanceVectorRouteEntry<T>
Represents a distance-vector route entry with neighbor-based information
DistanceVectorRoutingAlgorithm<T>
Distance-Vector Routing Algorithm implementation
DistanceVectorRoutingTable<T>
Represents a complete distance-vector routing table
DoublyLinkedListNode<T>
DPoS
Delegated Proof of Stake (DPoS) - delegate scheduling
DQN
DQN wrapper with optional target network and configurable replay buffer
DsrNode
ECDSA
ECDSA digital signature algorithm implementation
ECDSACurve
ECDSA curve parameters (secp256k1)
ECDSAKeyPair
ECDSA key pair
ECDSASignature
ECDSA signature structure
ECPoint
Elliptic curve point
Ed25519Curve
Ed25519 curve parameters
EdDSA
EdDSA digital signature algorithm implementation
EdDSAKeyPair
EdDSA key pair
EdDSASignature
EdDSA signature structure
EdmondsKarpEdge<T>
Represents a flow network edge with capacity and flow
EdmondsKarpResult<T>
Edmonds-Karp with detailed flow information and path analysis
FBA
FlowEdge<T>
Represents a flow network edge with capacity and flow
FordFulkersonResult<T>
Ford-Fulkerson with detailed flow information
GAN
Simple GAN scaffolding using ANN heads for generator and discriminator.
GaussianNB
GeneticAlgorithm<T>
GradientBoostingClassifier
GradientBoostingRegressor
GRU
Minimal GRU wrapper delegating the final mapping to an ANN readout.
Huffman
KademliaNode
KBucket
Keccak256
Keccak-256 hash algorithm implementation
Keccak256Constants
Keccak-256 constants and round constants
KNNModel
Simple object wrapper for k-NN storing training data and exposing predict.
LayeredNode<T>
Represents a node in the layered network with its level
LightGBMLikeRegressor
LinearRegressionModel
Thin object wrapper around the functional API to provide a uniform fit/predict interface used across the ML modules.
LinkedListNode<T>
LinkStateAdvertisement<T>
Represents a link-state advertisement (LSA) with network information
LinkStateDatabase<T>
Represents a complete link-state database for the network
LinkStateEntry<T>
Represents a link-state entry with complete network information
LinkStateRouteEntry<T>
Represents a routing table entry with complete path information
LinkStateRoutingAlgorithm<T>
Link-State Routing Algorithm implementation
LinkStateRoutingTable<T>
Represents a complete link-state routing table
ListEquality
LogisticRegressionModel
Thin adapter providing a fit/predict interface for logistic regression.
LRUCache<K, V>
A generic implementation of an LRU (Least Recently Used) Cache.
LSTM
Lightweight LSTM wrapper delegating trainable readout to ANN.
LZW
MCFEdge
MCTS<S>
MCTSNode<S>
MDP
MinCostFlow
MineResult
Result of a mining attempt.
MRUCache<K, V>
Implements a Most Recently Used (MRU) Cache with fixed capacity.
MultiSet<T>
Implements a MultiSet (Bag) with union, intersection, difference, and count operations.
NeighborAdvertisement<T>
Represents a neighbor advertisement with routing information
OSPFAlgorithm<T>
OSPF Algorithm implementation with area support and link-state database
OSPFRouteEntry<T>
Represents a routing table entry with OSPF-specific information
OSPFRoutingTable<T>
Represents the OSPF routing table with area support
ParticleSwarm<T>
PBFT
Plot
PoA
PoA helper with rotation policies and deterministic leader derivation.
PoB
Proof of Burn ledger with optional decay to model time-discounted burns.
PoET
PolicyGradient
REINFORCE-style Policy Gradient with optional baseline and normalization
PoS
PoS toolkit with a registry and deterministic, reproducible selection.
PPO
PriorityQueue<T>
Simple priority queue implementation for A* algorithm
ProofOfCapacity
Proof of Capacity simulation helpers.
ProofOfWork
Proof-of-Work helper built for deterministic simulation and testing.
QLearning
Tabular Q-Learning (advanced)
RandomForestClassifier
RIPAlgorithm<T>
RIP Algorithm implementation with configurable parameters
RIPEMD160
RIPEMD-160 hash algorithm implementation
RIPEMD160Constants
RIPEMD-160 hash constants and initial values
RLE
RNN
Minimal RNN wrapper using an MLP readout to keep implementation concise
RouteEntry<T>
Represents a routing table entry with destination and routing information
RoutingTable<T>
Represents a complete routing table for a node
SARSA
SARSA (on-policy TD control) with optional schedules and helpers
Scrypt
Scrypt key derivation function implementation
ScryptMining
Scrypt mining algorithm implementation for cryptocurrency mining
ScryptMiningParams
Scrypt mining parameters for different cryptocurrencies
SHA256
SHA-256 hash algorithm implementation
SHA256Constants
SHA-256 hash constants and initial values
SimulatedAnnealing<T>
SVMModel
Thin wrapper providing fit/predict interface for the linear SVM.
TarjansDetailedResult<T>
Enhanced Tarjan's algorithm with detailed analysis
TarjansResult<T>
Result of Tarjan's algorithm containing bridges and articulation points
ThreadedBinaryTreeNode<T>
Transformer
Minimal Transformer encoder wrapper. We provide a tiny, testable abstraction: token embeddings -> mean pooling -> MLP head (ANN).
UnionFindDetailed<T>
Enhanced Union-Find with detailed statistics and analysis
UnionFindNode<T>
Represents a node in the Union-Find data structure
Validator
WeightedEdge<T>
XGBoostLikeRegressor

Enums

Argon2Variant
Argon2 variants
BGPOrigin
BGP origin types
LinkStateStatus
Link state status enumeration
LinkStateType
Types of link-state advertisements

Functions

adaptiveSimpson(double f(double), double a, double b, {double tol = 1e-12, int maxRecursion = 20}) double
Adaptive Simpson integrator.
adaptiveTimeoutForHost(String host, Duration base) Duration
addTwoNumbersLinkedList(LinkedListNode<int>? l1, LinkedListNode<int>? l2) LinkedListNode<int>?
allPairsWithSum(List<int> nums, int target) List<List<int>>
Finds all pairs of numbers in a list that sum to a target value using a map.
areAnagrams(String str1, String str2) bool
Checks whether two strings str1 and str2 are anagrams of each other.
articulationPoints<T>(Map<T, List<T>> graph) Set<T>
aStar<T>(Map<T, Map<T, num>> graph, T start, T goal, num heuristic(T node, T goal), {int maxIterations = 10000}) List<T>
A* pathfinding algorithm implementation
aStarWithCost<T>(Map<T, Map<T, num>> graph, T start, T goal, num heuristic(T node, T goal), {int maxIterations = 10000}) AStarResult<T>
atoi(String s) int
String to Integer (Atoi): Converts a string to an integer, handling optional +/- and whitespace. Converts a string s to an integer, handling optional +/- and whitespace (Atoi).
averageOfSubarraysOfSizeK<T extends num>(List<T> list, int k) List<double>
📊 Computes the average of all contiguous subarrays of size k in a list of numbers.
bellmanFord<T>(Set<T> nodes, List<WeightedEdge<T>> edges, T start) Map<T, num>
bfs<T>(Map<T, List<T>> graph, T start) List<T>
binarySearch<T extends Comparable>(List<T> list, T target) int
bisection<T extends num>(double f(double x), T a, T b, {int maxIter = 200, double tol = 1e-12}) double
Robust Bisection root finder.
bitonicSort<T extends Comparable>(List<T> arr, {bool ascending = true}) → void
Sorts a list in-place using the Bitonic Sort algorithm (for lengths that are powers of 2).
bottomView<T>(BinaryTreeNode<T>? root) List<T>
boundaryTraversal<T>(BinaryTreeNode<T>? root) List<T>
boyerMooreSearch(String text, String pattern) int
Searches for the first occurrence of a pattern in a text using the Boyer-Moore algorithm.
bruteForceSearch(String text, String pattern) int
Performs a brute force search of the pattern string within the text string.
bubbleSort<T extends Comparable>(List<T> list) → void
🫧 Bubble Sort Algorithm (Generic)
bucketSort(List<double> arr) → void
Sorts a list of non-negative doubles using the Bucket Sort algorithm.
buildLPS(String pattern) List<int>
Builds the Longest Prefix Suffix (LPS) array used in KMP algorithm.
buildTreeFromInorderPostorder<T>(List<T> inorder, List<T> postorder) BinaryTreeNode<T>?
buildTreeFromInorderPreorder<T>(List<T> inorder, List<T> preorder) BinaryTreeNode<T>?
bwtInverse(List<int> transformedWithIndex) List<int>
bwtTransform(List<int> input) List<int>
canJump(List<int> nums) bool
🏃 Jump Game (Dynamic Programming / Greedy)
canPartition(List<int> nums) bool
⚖️ Partition Equal Subset Sum (Dynamic Programming)
cherryPickup(List<List<int>> grid) int
chinesePostman<T>(Map<T, Map<T, num>> graph) num?
Chinese Postman Problem (Route Inspection) for undirected graphs.
coinChange(List<int> coins, int amount) int
Solves the coin change problem using dynamic programming to find the minimum number of coins needed for a given amount.
coinChangeBottomUp(List<int> coins, int amount) int
🪙 Minimum Coin Change (Bottom-Up)
combinationSum(List<int> candidates, int target) List<List<int>>
Finds all unique combinations of numbers that sum to a target using backtracking.
combine(int n, int k) List<List<int>>
Generates all possible combinations of k numbers out of the range 1 to n using backtracking.
combSort<T extends Comparable>(List<T> arr) → void
Sorts a list in-place using the Comb Sort algorithm.
compressString(String input) String
Compresses the input string by replacing consecutive repeated characters with the character followed by the count of repetitions.
computeBGPRoutes<T>(Map<T, Map<T, num>> asTopology, T sourceAS, {Map<String, dynamic>? policies}) BGPRoutingTable<T>
Convenience function for quick BGP route computation
computeDistanceVectorRoutes<T>(Map<T, Map<T, num>> network, T sourceNode, {Map<T, NeighborAdvertisement<T>>? initialAdvertisements}) DistanceVectorRoutingTable<T>
Convenience function for quick distance-vector route computation
computeLinkStateRoutes<T>(Map<T, Map<T, num>> network, T sourceNode, {Map<String, dynamic>? topologyOptimizations}) LinkStateRoutingTable<T>
Convenience function for quick link-state route computation
computeOSPFRoutes<T>(Map<T, Map<T, num>> network, T sourceRouter, {int areaId = 0}) OSPFRoutingTable<T>
Convenience function for quick OSPF route computation
computePrefixSum<T extends num>(List<T> list) List<T>
Computes the prefix sum list of the input list.
computeRIPRoutes<T>(Map<T, Map<T, num>> network, T sourceNode, {int maxHops = 15}) RoutingTable<T>
Convenience function for quick route computation
connectedComponents<T>(Map<T, List<T>> graph) List<Set<T>>
convertBinaryLinkedListToInt(LinkedListNode<int>? head) int
countFullNodes<T>(BinaryTreeNode<T>? root) int
countHalfNodes<T>(BinaryTreeNode<T>? root) int
countingSort(List<int> list) List<int>
🧮 Counting Sort Algorithm (for non-negative integers only)
countLeafNodes<T>(BinaryTreeNode<T>? root) int
countPairsWithDiff(List<int> nums, int diff) int
Counts the number of unique pairs with a specific difference in a list.
countPalindromicSubsequences(String s) int
🔁 Count Palindromic Substrings (DP)
countVowelsAndConsonants(String text) Map<String, int>
Counts the number of vowels and consonants in a given text.
cycleSort<T extends Comparable>(List<T> arr) → void
Sorts a list in-place using the Cycle Sort algorithm (minimizes writes).
deleteAtPosition<T>(LinkedListNode<T>? head, int position) LinkedListNode<T>?
Deletes the node at the specified position
deleteByValue<T>(LinkedListNode<T>? head, T value) LinkedListNode<T>?
Deletes the first node with the specified value
derivative(double f(double), double x, {double h = 1e-4, bool richardson = true}) double
Compute derivative f'(x) using a high-order central finite-difference.
deserializeTree<T>(String data) BinaryTreeNode<T>?
Deserializes a string back to a binary tree
detectAndRemoveLoop<T>(LinkedListNode<T>? head) bool
detectCycle<T>(LinkedListNode<T>? head) bool
Detects if a cycle exists in the linked list using Floyd's algorithm
detectCycleWithHashSet<T>(LinkedListNode<T>? head) bool
Detects cycle using hash set approach (alternative method)
detectWafCdns(Map<String, String>? headers, String? cname) List<String>
dfs<T>(Map<T, List<T>> graph, T start) List<T>
dijkstra<T>(Map<T, List<WeightedEdge<T>>> graph, T start) Map<T, num>
dinicsAlgorithm<T>(Map<T, Map<T, num>> graph, T source, T sink) num
Dinic's maximum flow algorithm implementation
dinicsAlgorithmDetailed<T>(Map<T, Map<T, num>> graph, T source, T sink) DinicsResult<T>
editDistance(String word1, String word2) int
Computes the Edit Distance (Levenshtein Distance) between two strings.
edmondsBlossom(int n, List<List<int>> g) List<int>
edmondsKarp<T>(Map<T, Map<T, num>> graph, T source, T sink) num
Edmonds-Karp maximum flow algorithm implementation
edmondsKarpDetailed<T>(Map<T, Map<T, num>> graph, T source, T sink) EdmondsKarpResult<T>
expandCidr(String cidr) List<String>
expandCidrLazy(String cidr) Iterable<String>
fibonacciMemo(int n, [Map<int, int>? memo]) int
🧮 Fibonacci with Memoization (Dynamic Programming)
findBridges<T>(Map<T, List<T>> graph) List<List<T>>
Bridge Finding Algorithm (Tarjan's) for undirected graphs.
findCycleStart<T>(LinkedListNode<T>? head) LinkedListNode<T>?
Finds the starting node of the cycle if it exists
findDuplicates<T>(List<T> list) List<T>
🔁 Returns a list of duplicate elements from the input list.
findEulerianPath<T>(Map<T, List<T>> graph, {bool directed = false}) List<T>?
Eulerian Path and Circuit Finder for directed or undirected graphs.
findHamiltonianPath<T>(Map<T, List<T>> graph, {bool cycle = false}) List<T>?
Hamiltonian Path and Cycle Finder using backtracking.
findIntersection<T>(List<T> list1, List<T> list2) List<T>
Returns the intersection between two lists of type T.
findMax<T extends Comparable<T>>(List<T> list) → T
📌 Finds the maximum value in a list of comparable elements.
findMin<T extends Comparable<T>>(List<T> list) → T
📌 Finds the minimum value in a list of comparable elements.
findSubarraysWithSum(List<int> nums, int target) List<List<int>>
Finds all subarrays whose sum equals the target using prefix sum and a map.
fingerprintService({Map<String, String>? headers, String? banner}) Map<String, dynamic>
firstNonRepeatedElement<T>(List<T> input) → T?
Finds the first non-repeated character in a generic list of elements.
flattenBinaryTreeToLinkedList<T>(BinaryTreeNode<T>? root) → void
floodFill<T>(List<List<T>> matrix, int sr, int sc, T newValue) List<List<T>>
🖨️ Flood Fill (DFS, Generic)
floydWarshall<T>(Set<T> nodes, List<WeightedEdge<T>> edges) Map<T, Map<T, num>>
fordFulkerson<T>(Map<T, Map<T, num>> graph, T source, T sink) num
Ford-Fulkerson maximum flow algorithm implementation
fordFulkersonDetailed<T>(Map<T, Map<T, num>> graph, T source, T sink) FordFulkersonResult<T>
frequencyCount<T>(List<T> items) Map<T, int>
Returns a Map containing the frequency count of each unique element in items.
gaussLegendreFixedOrder(double f(double), double a, double b, {int order = 5}) double
Gauss-Legendre fixed order integrator (orders 2..5).
geoIpLookup(String ip, {Duration timeout = const Duration(seconds: 5)}) Future<Map<String, dynamic>?>
getCycleLength<T>(LinkedListNode<T>? head) int
Calculates the length of the cycle if it exists
getIntersectionNode<T>(LinkedListNode<T>? headA, LinkedListNode<T>? headB) LinkedListNode<T>?
Finds the intersection point of two linked lists
getIntersectionNodeOptimized<T>(LinkedListNode<T>? headA, LinkedListNode<T>? headB) LinkedListNode<T>?
Finds the intersection point using length and two-pointer technique
getIntersectionNodeTwoPointer<T>(LinkedListNode<T>? headA, LinkedListNode<T>? headB) LinkedListNode<T>?
Finds the intersection point using two-pointer technique
getIntersectionNodeWithHashSet<T>(LinkedListNode<T>? headA, LinkedListNode<T>? headB) LinkedListNode<T>?
Finds the intersection point using hash set approach
getIntersectionNodeWithInfo<T>(LinkedListNode<T>? headA, LinkedListNode<T>? headB) Map<String, dynamic>
Finds the intersection point and returns additional information
getLength<T>(LinkedListNode<T>? head) int
Helper function to get the length of a linked list
gnomeSort<T extends Comparable>(List<T> arr) → void
Sorts a list in-place using the Gnome Sort algorithm.
grabBanner(String host, int port, {Duration timeout = const Duration(milliseconds: 300), Duration bannerTimeout = const Duration(milliseconds: 300)}) Future<String?>
Do a tiny banner grab via TCP socket and return the first line (trimmed), or null on error.
graphColoring<T>(Map<T, List<T>> graph, int m) Map<T, int>?
Graph Coloring (m-coloring problem) using backtracking.
groupAnagrams(List<String> words) List<List<String>>
Groups words that are anagrams of each other.
groupByFirstLetter(List<String> words) Map<String, List<String>>
groupByKey<T, K>(List<T> items, K keySelector(T)) Map<K, List<T>>
Groups the elements of items using the provided keySelector function which extracts a key of type K from each element of type T.
hasCycleDirected<T>(Map<T, List<T>> graph) bool
hasCycleUndirected<T>(Map<T, List<T>> graph) bool
hasDuplicates<T>(List<T> list) bool
Checks if the input list contains any duplicate elements.
hasPathSum<T extends num>(List<List<T>> matrix, T target) bool
➕ Path Sum in Matrix (DFS, Generic)
hasTwoSum<T extends num>(List<T> nums, T target) bool
Checks if there exists a pair of elements in nums whose sum equals target.
hasUniqueWindow<T>(List<T> nums, int k) bool
Checks whether there exists a subwindow of length k in nums such that all its elements are unique.
heapSort<T extends Comparable>(List<T> arr) → void
Sorts a list in-place using the Heap Sort algorithm.
hierholzer<T>(Map<T, List<T>> graph) List<T>?
Hierholzer's Algorithm for finding an Eulerian trail/circuit in a graph.
houseRobber(List<int> nums) int
🏠 House Robber (Dynamic Programming)
httpHeadProbe(String host, {Duration timeout = const Duration(seconds: 5)}) Future<Map<String, dynamic>>
Performs a lightweight HTTP HEAD probe returning headers map and resolved first IP (or null). Does not throw — returns nulls on failure.
hungarian(List<List<int>> cost) List
identifyProtocolFromBanner(String banner) String
indexMapping<T>(List<T> list) Map<T, List<int>>
Maps each element in a list to a list of indices where it appears.
inorderTraversal<T>(BinaryTreeNode<T>? root) List<T>
Inorder Traversal: Left -> Root -> Right
insertAfterValue<T>(LinkedListNode<T>? head, T afterValue, T newValue) LinkedListNode<T>?
Inserts a new node with the given value after a node with the specified value
insertAtPosition<T>(LinkedListNode<T>? head, T value, int position) LinkedListNode<T>?
Inserts a new node with the given value at the specified position
insertionSort<T extends Comparable>(List<T> list) → void
🧩 Insertion Sort Algorithm (Generic)
inspectTlsCertificate(String host, int port, {Duration timeout = const Duration(seconds: 5)}) Future<Map<String, dynamic>?>
Inspect TLS certificate information for a host:port. Same semantics as the original inline implementation in scanner.dart: returns null on error.
intersectionDetectionHashSet<T>(LinkedListNode<T>? headA, LinkedListNode<T>? headB) LinkedListNode<T>?
intToRoman(int num) String
Converts an integer to its Roman numeral representation.
invertMap<K, V>(Map<K, V> map) Map<V, K>
Inverts a map by swapping keys and values. If duplicate values exist, later keys overwrite earlier ones.
invertTree<T>(BinaryTreeNode<T>? root) BinaryTreeNode<T>?
isAnagram<T>(List<T> seq1, List<T> seq2) bool
Checks if two sequences are anagrams of each other.
isBalancedTree<T>(BinaryTreeNode<T>? root) bool
isBipartite<T>(Map<T, List<T>> graph) bool
isDisjoint<T>(Set<T> a, Set<T> b) bool
Checks if two sets a and b are disjoint (no elements in common).
isFrequencyUnique<T>(List<T> list) bool
Checks if the frequencies of elements in the list are all unique.
isInterleave(String s1, String s2, String s3) bool
🔁 Interleaving String
isPalindrome<T>(LinkedListNode<T>? head) bool
Checks if a linked list is a palindrome
isPalindromeRecursive<T>(LinkedListNode<T>? head) bool
Checks if a linked list is a palindrome using recursive approach
isPalindromes(String text) bool
Checks if the given text is a palindromes.
isPalindromeWithArray<T>(LinkedListNode<T>? head) bool
Checks if a linked list is a palindrome using array approach
isPalindromeWithStack<T>(LinkedListNode<T>? head) bool
Checks if a linked list is a palindrome using stack approach
isPrivateIp(String ip) bool
isRegexMatch(String s, String p) bool
🔎 Regular Expression Matching (DP)
isSubset<T>(Set<T> a, Set<T> b) bool
Checks if set a is a subset of set b.
isSuperset<T>(Set<T> a, Set<T> b) bool
Checks if set a is a superset of set b.
isWildcardMatch(String s, String p) bool
  • Wildcard Matching (DP)
  • johnsonsAlgorithm<T>(Map<T, Map<T, num>> graph) Map<T, Map<T, num>>
    Johnson's Algorithm for All-Pairs Shortest Paths in a weighted, directed graph.
    kadanesAlgorithm<T extends num>(List<T> list) → T
    📈 Returns the maximum sum of a contiguous subarray using Kadane's Algorithm (Generic for num).
    kmpSearch(String text, String pattern) int
    Performs KMP search of pattern within text.
    knapsack01(List<int> weights, List<int> values, int capacity) int
    🎒 0/1 Knapsack Problem (Dynamic Programming)
    knnPredict(List<List<double>> X, List<int> y, List<double> q, int k) int
    kosarajuSCC<T>(Map<T, List<T>> graph) List<Set<T>>
    kruskalMST<T>(Set<T> nodes, List<WeightedEdge<T>> edges) List<WeightedEdge<T>>
    lengthOfLongestSubstring(String s) int
    Finds the length of the longest substring without repeating characters in s.
    letterCombinations(String digits) List<String>
    Generates all possible letter combinations for a phone number using backtracking.
    levelOrderTraversal<T>(BinaryTreeNode<T>? root) List<List<T>>
    linearRegressionFit(List<List<double>> X, List<double> y) List<double>
    linearRegressionPredict(List<double> coeffs, List<double> features) double
    linearSearch<T>(List<T> list, T target) int
    🔍 Linear Search Algorithm (Generic)
    lisBinarySearch(List<int> nums) int
    Finds the length of the longest strictly increasing subsequence in a list using binary search (O(n log n)).
    listEquals<T>(List<T> list1, List<T> list2) bool
    Helper function to check if two lists are equal element-wise.
    listToSetPreserveOrder<T>(List<T> list) List<T>
    Converts a list to a set (as a list) while preserving the order of first occurrence.
    logisticRegressionFit(List<List<double>> X, List<int> y, {double lr = 0.1, int epochs = 500}) List<double>
    logisticRegressionPredictClass(List<double> weights, List<double> features, {double threshold = 0.5}) int
    longestAlternatingSubsequence(List<int> nums) int
    Finds the length of the longest alternating (up/down) subsequence in a list using dynamic programming.
    longestBitonicSubsequence(List<int> arr) int
    🔺 Longest Bitonic Subsequence (DP)
    longestCommonPrefix(List<String> strs) String
    Finds the longest common prefix string amongst an array of strings.
    longestCommonSubsequence(String a, String b) int
    🔗 Longest Common Subsequence (LCS) - Dynamic Programming
    longestIncreasingSubsequence<T extends Comparable>(List<T> items) int
    📈 Longest Increasing Subsequence (LIS, Generic) - O(n log n)
    longestPalindrome(String s) String
    Returns the longest palindromic substring in the given string s.
    longestRepeatingSubstring(String s) String
    Finds the longest substring in a string that appears at least twice using binary search and rolling hash.
    lowestCommonAncestor<T>(BinaryTreeNode<T>? root, T p, T q) BinaryTreeNode<T>?
    Returns the lowest common ancestor node of values p and q in the binary tree rooted at root. Returns null if either p or q is not present in the tree.
    luDecomposition(List<List<double>> A) List<Map<String, dynamic>>
    LU decomposition with partial pivoting (Doolittle algorithm).
    manacherLongestPalindrome(String s) String
    Finds the longest palindromic substring in a string using Manacher's Algorithm (O(n) time).
    matrixChainOrder(List<int> dims) int
    📐 Matrix Chain Multiplication (DP)
    max<T extends num>(T a, T b) → T
    Utility function for finding maximum of two numbers
    maxCoins(List<int> nums) int
    maxProductSubarray(List<double> nums) double
    Finds the maximum product of a contiguous subarray in a list using dynamic programming.
    maxSumIncreasingSubsequence(List<int> arr) int
    📈 Maximum Sum Increasing Subsequence (DP)
    maxSumSubarrayOfSizeK<T extends num>(List<T> list, int k) → T
    🔍 Returns the maximum sum of any contiguous subarray of size k using the Sliding Window technique (Generic for num).
    mergeKSortedLists<T extends Comparable>(List<LinkedListNode<T>?> lists) LinkedListNode<T>?
    Merges K sorted linked lists efficiently
    mergeMaps<K, V>(Map<K, V> a, Map<K, V> b, V conflict(K, V, V)) Map<K, V>
    Merges two maps with custom conflict resolution for duplicate keys.
    mergeSort<T extends Comparable>(List<T> list) List<T>
    🧠 Merge Sort Algorithm
    mergeSortedLists<T extends Comparable>(LinkedListNode<T>? list1, LinkedListNode<T>? list2) LinkedListNode<T>?
    Merges two sorted linked lists iteratively
    mergeSortedListsInPlace<T extends Comparable>(LinkedListNode<T>? list1, LinkedListNode<T>? list2) LinkedListNode<T>?
    Merges two sorted linked lists in-place (modifies the original lists)
    mergeSortedListsRecursive<T extends Comparable>(LinkedListNode<T>? list1, LinkedListNode<T>? list2) LinkedListNode<T>?
    Merges two sorted linked lists recursively
    mergeSortedListsWithComparator<T>(LinkedListNode<T>? list1, LinkedListNode<T>? list2, int comparator(T, T)) LinkedListNode<T>?
    Merges two sorted linked lists with custom comparator
    mergeSortLinkedList<T extends Comparable>(LinkedListNode<T>? head) LinkedListNode<T>?
    minCostPaintHouse(List<List<int>> costs) int
    🏠 Paint House (DP)
    minCutsPalindromePartition(String s) int
    ✂️ Minimum Cuts for Palindrome Partitioning (DP)
    minimumPathSum(List<List<int>> grid) int
    📉 Minimum Path Sum in Grid
    minPathSum(List<List<int>> grid) int
    🧮 Matrix Path Sum (Minimum Path Sum in Grid)
    minSumSubarrayOfSizeK<T extends num>(List<T> list, int k) → T
    Returns the minimum sum of any subarray with size k using Sliding Window (Generic for num).
    minWindowSubsequence(String s, String t) String
    Finds the minimum window in string s that contains string t as a subsequence.
    minWindowSubstring(String s, String t) String
    Finds the minimum window substring in s containing all characters of t using a map and sliding window.
    morrisInorderTraversal<T>(BinaryTreeNode<T>? root) List<T>
    mostFrequentElement<T>(List<T> list) → T?
    Finds the most frequent element in a list of generic type T.
    newtonRaphson<T extends num>(double f(double x), double df(double x)?, T initialGuess, {int maxIter = 100, double tol = 1e-12, double epsDerivative = 1e-12}) double
    High-performance Newton–Raphson root finder with optional numeric derivative.
    numDecodings(String s) int
    🔐 Decode Ways (number of decodings)
    numIslandsBFS(List<List<String>> grid) int
    Counts the number of islands (connected groups of '1's) in a 2D grid using BFS.
    numIslandsDFS(List<List<String>> grid) int
    🏝️ Island Count using Depth-First Search (DFS)
    oddEvenSort<T extends Comparable>(List<T> arr) → void
    Sorts a list in-place using the Odd-Even Sort (Brick Sort) algorithm.
    pancakeSort<T extends Comparable>(List<T> arr) → void
    Sorts a list in-place using the Pancake Sort algorithm.
    partitionList<T extends Comparable>(LinkedListNode<T>? head, T x) LinkedListNode<T>?
    permutations<T>(List<T> items) List<List<T>>
    🔄 Permutations (Backtracking, Generic)
    pigeonholeSort(List<int> arr) → void
    Sorts a list of integers in-place using the Pigeonhole Sort algorithm.
    postorderTraversal<T>(BinaryTreeNode<T>? root) List<T>
    Postorder Traversal: Left -> Right -> Root
    powerSet<T>(Set<T> input) List<Set<T>>
    Generates the power set (all subsets) of the input set.
    predictLinearSVM(List<double> model, List<double> x) int
    preorderTraversal<T>(BinaryTreeNode<T>? root) List<T>
    Preorder Traversal: Root -> Left -> Right
    primMST<T>(Map<T, List<WeightedEdge<T>>> graph) List<WeightedEdge<T>>
    printAllRootToLeafPaths<T>(BinaryTreeNode<T>? root) List<List<T>>
    printResult<T>(List<T> input) → void
    Helper function to print the result for a list of generic elements.
    prioritizeHosts(List<String> hosts, {String ordering = 'linkstate'}) List<String>
    qrDecomposition(List<List<double>> A) Map<String, List<List<double>>>
    quickselect<T extends Comparable>(List<T> arr, int k) → T
    ⚡ Quickselect Algorithm
    quickSort<T extends Comparable>(List<T> list, int low, int high) → void
    🧠 Quick Sort Algorithm (Generic Version)
    rabinKarpSearch(String text, String pattern) int
    Rabin-Karp algorithm for substring search.
    radixSort(List<int> arr) → void
    🧮 Radix Sort (Least Significant Digit)
    rangeSum<T extends num>(List<T> prefix, int i, int j) → T
    Returns the sum from index i to j using a prefix sum list.
    ratInMaze(List<List<int>> maze) List<String>
    Finds all possible paths for a rat to reach the bottom-right corner from the top-left in a maze using backtracking.
    removeConsecutiveDuplicates(String s) String
    Removes consecutive duplicate characters from a string s.
    removeCycle<T>(LinkedListNode<T>? head) LinkedListNode<T>?
    Removes the cycle from the linked list if it exists
    removeDuplicates<T>(List<T> list) List<T>
    Removes duplicates from a given list while preserving the original order.
    removeDuplicatesSortedList<T>(LinkedListNode<T>? head) LinkedListNode<T>?
    removeNthFromEnd<T>(LinkedListNode<T>? head, int n) LinkedListNode<T>?
    Removes the nth node from the end of the linked list
    removeNthFromEndRecursive<T>(LinkedListNode<T>? head, int n) LinkedListNode<T>?
    Removes the nth node from the end using recursive approach
    removeNthFromEndSinglePass<T>(LinkedListNode<T>? head, int n) LinkedListNode<T>?
    Removes the nth node from the end using single pass with length calculation
    removeNthFromEndWithReturn<T>(LinkedListNode<T>? head, int n) Map<String, LinkedListNode<T>?>
    Removes the nth node from the end and returns both the new head and the removed node
    reverseBetween<T>(LinkedListNode<T>? head, int left, int right) LinkedListNode<T>?
    Reverses the nodes between two positions (inclusive)
    reverseDoublyLinkedList<T>(DoublyLinkedListNode<T>? head) DoublyLinkedListNode<T>?
    Reverses a doubly linked list
    reverseInGroups<T>(LinkedListNode<T>? head, int k) LinkedListNode<T>?
    Reverses a linked list in groups of specified size
    reverseLinkedList<T>(LinkedListNode<T>? head) LinkedListNode<T>?
    Reverses a singly linked list iteratively
    reverseLinkedListRecursive<T>(LinkedListNode<T>? head) LinkedListNode<T>?
    Reverses a singly linked list recursively
    reverseList<T>(List<T> list) → void
    🔁 Reverse List (In-place)
    reverseNodesInKGroup<T>(LinkedListNode<T>? head, int k) LinkedListNode<T>?
    reverseString(String input) String
    Reverses the given input string.
    rodCutting(List<int> prices, int n) int
    🪚 Rod Cutting (Dynamic Programming)
    rollingHashSearch(String text, String pattern) List<int>
    Rolling Hash for Substring Matching (Rabin-Karp): Returns all start indices where pattern occurs in text. Uses a rolling hash (Rabin-Karp) to find all start indices where pattern occurs in text.
    romanToInt(String s) int
    Converts a Roman numeral string to its integer representation.
    rotateArrayRight<T>(List<T> list, int k) List<T>
    Rotates a list k steps to the right.
    rotateLinkedList<T>(LinkedListNode<T>? head, int k) LinkedListNode<T>?
    rotateMatrix(List<List<int>> matrix) → void
    Rotates a square matrix (n x n) 90 degrees clockwise in-place.
    selectionSort<T extends Comparable>(List<T> list) → void
    🎯 Selection Sort Algorithm (Generic)
    serializeTree<T>(BinaryTreeNode<T>? root) String
    Serializes a binary tree to a string representation
    serviceSeverity(String service, int port) Map<String, dynamic>
    setDifference<T>(List<T> listA, List<T> listB) List<T>
    Returns a list of elements that are in listA but not in listB.
    severitySummary(Map<String, Map<int, Map<String, dynamic>>> results) Map<String, dynamic>
    shellSort<T extends Comparable>(List<T> arr) → void
    🐚 Shell Sort Algorithm
    shortestPathInGrid(List<List<int>> grid) int
    Finds the length of the shortest path from (0,0) to (m-1,n-1) in a binary grid using BFS.
    shortestPathUnweighted<T>(Map<T, List<T>> graph, T start, T target) List<T>
    solveNQueens(int n) List<List<String>>
    Solves the N-Queens problem using backtracking and returns all valid board configurations.
    solveSudoku(List<List<String>> board) bool
    Solves a 9x9 Sudoku puzzle in-place using backtracking.
    solveSurroundedRegions(List<List<String>> board) → void
    Captures all regions surrounded by 'X' in a 2D board using DFS.
    sortedArrayToBST<T extends Comparable>(List<T> arr) BinaryTreeNode<T>?
    spfa<T>(Map<T, Map<T, num>> graph, T source) Map<T, num>
    Shortest Path Faster Algorithm (SPFA) for single-source shortest paths in a weighted, directed graph.
    spiralOrder<T>(List<List<T>> matrix) List<T>
    🌀 Spiral Traversal of Matrix (Generic)
    stoerWagnerMinCut<T>(Map<T, Map<T, num>> graph) num?
    Stoer-Wagner Algorithm for Global Minimum Cut in an undirected, weighted graph.
    stoogeSort<T extends Comparable>(List<T> arr, [int i = 0, int? j]) → void
    🧙 Stooge Sort Algorithm
    stringPermutations(String s) List<String>
    Generates all unique permutations of a given string.
    subsets<T>(List<T> nums) List<List<T>>
    Generates all possible subsets (the power set) of a given list using backtracking.
    subsetSum<T extends num>(List<T> nums, T target) bool
    🔢 Subset Sum (Dynamic Programming, Generic)
    swapNodesInPairs<T>(LinkedListNode<T>? head) LinkedListNode<T>?
    symmetricDifference<T>(Set<T> a, Set<T> b) Set<T>
    Returns the symmetric difference of two sets: elements in either set, but not both.
    tarjansAlgorithm<T>(Map<T, List<T>> graph) TarjansResult<T>
    Tarjan's algorithm for finding bridges and articulation points
    tarjansAlgorithmDetailed<T>(Map<T, List<T>> graph) TarjansDetailedResult<T>
    Enhanced Tarjan's algorithm with detailed analysis
    tarjansSCC<T>(Map<T, List<T>> graph) List<List<T>>
    Tarjan's Algorithm for finding Strongly Connected Components (SCC) in a directed graph.
    threadedInorderTraversal<T>(ThreadedBinaryTreeNode<T>? root) List<T>
    topKFrequent<T>(List<T> items, int k) List<T>
    Returns the top K most frequent elements in the list items.
    topologicalSort<T>(Map<T, List<T>> graph) List<T>
    topView<T>(BinaryTreeNode<T>? root) List<T>
    traceroute(String host, {int maxHops = 30}) Future<List<String>>
    trainLinearSVM(List<List<double>> X, List<int> y, {double lr = 0.01, int epochs = 500, double C = 1.0}) List<double>
    transitiveClosure<T>(Map<T, List<T>> graph) Map<T, Map<T, bool>>
    Transitive Closure of a directed graph using Floyd-Warshall algorithm.
    treeDepth<T>(BinaryTreeNode<T>? root) int
    treeDiameter<T>(Map<T, List<T>> tree) Map<String, dynamic>
    Computes the diameter of a tree (longest path between any two nodes).
    twoSum<T>(List<T> nums, T target) List<int>?
    Finds two indices in the list nums whose elements sum up to target.
    twoSumSorted<T extends num>(List<T> list, T target) List<T>?
    🔢 Two Sum in Sorted List (Two-Pointer Technique)
    uniquePathsWithObstacles(List<List<int>> obstacleGrid) int
    🚧 Unique Paths with Obstacles
    updateRtt(String host, double sampleMs) → void
    validateBST<T extends Comparable>(BinaryTreeNode<T>? root) bool
    verticalOrderTraversal<T>(BinaryTreeNode<T>? root) List<List<T>>
    wellKnownPortService(int port) String
    wordFrequencyRanking(String text) List<String>
    Ranks words in a text by frequency (descending), then lexicographically for ties.
    wordSearch(List<List<String>> board, String word) bool
    Searches for a word in a 2D grid using backtracking.
    yensAlgorithm<T>(Map<T, Map<T, num>> graph, T source, T target, int k) List<List<T>>
    Yen's Algorithm for finding the K shortest loopless paths between two nodes in a graph.
    zAlgorithm(String s) List<int>
    Computes the Z-array for pattern matching in string s (Z-Algorithm).
    zigzagTraversal<T>(BinaryTreeNode<T>? root) List<List<T>>

    Typedefs

    BigHash = BigInt Function(String data, int nonce)
    Hash function signature returning a BigInt-like value (lower = better).
    DeliveryCallback = void Function(int from, int to, dynamic payload)
    Callback type invoked when a node delivers a payload to its destination.
    Expand<S> = List Function(S state)
    IsTerminal<S> = bool Function(S state)
    NextState<S> = S Function(S state, dynamic action)
    Reward<S> = double Function(S state)
    UnionFind<T> = DisjointSet<T>