{"id":68279,"date":"2024-07-05T22:05:21","date_gmt":"2024-07-05T18:35:21","guid":{"rendered":"https:\/\/nabfollower.com\/blog\/2058-find-the-minimum-and-maximum-number-of-nodes-between-critical-points-13c3\/"},"modified":"2024-07-05T22:05:21","modified_gmt":"2024-07-05T18:35:21","slug":"2058-find-the-minimum-and-maximum-number-of-nodes-between-critical-points-13c3","status":"publish","type":"post","link":"https:\/\/nabfollower.com\/blog\/2058-find-the-minimum-and-maximum-number-of-nodes-between-critical-points-13c3\/","title":{"rendered":"2058. \u062d\u062f\u0627\u0642\u0644 \u0648 \u062d\u062f\u0627\u06a9\u062b\u0631 \u062a\u0639\u062f\u0627\u062f \u06af\u0631\u0647 \u0647\u0627 \u0631\u0627 \u0628\u06cc\u0646 \u0646\u0642\u0627\u0637 \u0628\u062d\u0631\u0627\u0646\u06cc \u0628\u06cc\u0627\u0628\u06cc\u062f."},"content":{"rendered":"<p>Summarize this content to 400 words in Persian Lang<br \/>\n            2058. \u062d\u062f\u0627\u0642\u0644 \u0648 \u062d\u062f\u0627\u06a9\u062b\u0631 \u062a\u0639\u062f\u0627\u062f \u06af\u0631\u0647 \u0647\u0627 \u0631\u0627 \u0628\u06cc\u0646 \u0646\u0642\u0627\u0637 \u0628\u062d\u0631\u0627\u0646\u06cc \u0628\u06cc\u0627\u0628\u06cc\u062f.<\/p>\n<p>\u0645\u062a\u0648\u0633\u0637<\/p>\n<p>\u0622 \u0646\u0642\u0637\u0647 \u0628\u062d\u0631\u0627\u0646\u06cc \u062f\u0631 \u06cc\u06a9 \u0644\u06cc\u0633\u062a \u067e\u06cc\u0648\u0646\u062f\u06cc \u0628\u0647 \u0639\u0646\u0648\u0627\u0646 \u062a\u0639\u0631\u06cc\u0641 \u0645\u06cc \u0634\u0648\u062f \u06cc\u0627 \u0622 \u062d\u062f\u0627\u06a9\u062b\u0631 \u0645\u062d\u0644\u06cc \u06cc\u0627 \u0627\u0644\u0641 \u062d\u062f\u0627\u0642\u0644 \u0647\u0627\u06cc \u0645\u062d\u0644\u06cc.<\/p>\n<p>\u06cc\u06a9 \u06af\u0631\u0647 \u06cc\u06a9 \u0627\u0633\u062a \u062d\u062f\u0627\u06a9\u062b\u0631 \u0645\u062d\u0644\u06cc \u0627\u06af\u0631 \u06af\u0631\u0647 \u0641\u0639\u0644\u06cc \u06cc\u06a9 \u0645\u0642\u062f\u0627\u0631 \u062f\u0627\u0634\u062a\u0647 \u0628\u0627\u0634\u062f \u0628\u0647 \u0634\u062f\u062a \u0628\u0632\u0631\u06af\u062a\u0631 \u0646\u0633\u0628\u062a \u0628\u0647 \u06af\u0631\u0647 \u0642\u0628\u0644\u06cc \u0648 \u06af\u0631\u0647 \u0628\u0639\u062f\u06cc.<\/p>\n<p>\u06cc\u06a9 \u06af\u0631\u0647 \u06cc\u06a9 \u0627\u0633\u062a \u062d\u062f\u0627\u0642\u0644 \u0647\u0627\u06cc \u0645\u062d\u0644\u06cc \u0627\u06af\u0631 \u06af\u0631\u0647 \u0641\u0639\u0644\u06cc \u06cc\u06a9 \u0645\u0642\u062f\u0627\u0631 \u062f\u0627\u0634\u062a\u0647 \u0628\u0627\u0634\u062f \u0628\u0647 \u0634\u062f\u062a \u06a9\u0648\u0686\u06a9\u062a\u0631 \u0646\u0633\u0628\u062a \u0628\u0647 \u06af\u0631\u0647 \u0642\u0628\u0644\u06cc \u0648 \u06af\u0631\u0647 \u0628\u0639\u062f\u06cc.<\/p>\n<p>\u062a\u0648\u062c\u0647 \u062f\u0627\u0634\u062a\u0647 \u0628\u0627\u0634\u06cc\u062f \u06a9\u0647 \u06cc\u06a9 \u06af\u0631\u0647 \u062a\u0646\u0647\u0627 \u062f\u0631 \u0635\u0648\u0631\u062a \u0648\u062c\u0648\u062f \u0645\u06cc \u062a\u0648\u0627\u0646\u062f \u062d\u062f\u0627\u06a9\u062b\u0631\/\u062d\u062f\u0627\u0642\u0644 \u0645\u062d\u0644\u06cc \u0628\u0627\u0634\u062f \u0647\u0631 \u062f\u0648 \u06cc\u06a9 \u06af\u0631\u0647 \u0642\u0628\u0644\u06cc \u0648 \u06cc\u06a9 \u06af\u0631\u0647 \u0628\u0639\u062f\u06cc.<\/p>\n<p>\u0628\u0627 \u062a\u0648\u062c\u0647 \u0628\u0647 \u06cc\u06a9 \u0644\u06cc\u0633\u062a \u067e\u06cc\u0648\u0646\u062f\u06cc head\u060c \u0628\u0631\u06af\u0634\u062a \u0622\u0631\u0627\u06cc\u0647 \u0627\u06cc \u0628\u0647 \u0637\u0648\u0644 2 \u0634\u0627\u0645\u0644 [minDistance, maxDistance] \u062c\u0627\u06cc\u06cc \u06a9\u0647 minDistance \u0647\u0633\u062a \u062d\u062f\u0627\u0642\u0644 \u0641\u0627\u0635\u0644\u0647 \u0628\u06cc\u0646 \u0647\u0631 \u062f\u0648 \u0645\u062a\u0645\u0627\u06cc\u0632 \u0646\u0642\u0627\u0637 \u0628\u062d\u0631\u0627\u0646\u06cc \u0648 maxDistance \u0647\u0633\u062a \u062d\u062f\u0627\u06a9\u062b\u0631 \u0641\u0627\u0635\u0644\u0647 \u0628\u06cc\u0646 \u0647\u0631 \u062f\u0648 \u0645\u062a\u0645\u0627\u06cc\u0632 \u0646\u0642\u0627\u0637 \u0628\u062d\u0631\u0627\u0646\u06cc.  \u0627\u06af\u0631 \u0648\u062c\u0648\u062f \u062f\u0627\u0631\u062f \u06a9\u0645\u062a\u0631 \u0627\u0632 \u062f\u0648 \u0646\u0642\u0637\u0647 \u0628\u062d\u0631\u0627\u0646\u06cc\u060c \u0628\u0627\u0632\u06af\u0634\u062a [-1, -1].<\/p>\n<p>\u0645\u062b\u0627\u0644 1:<\/p>\n<p>\u0648\u0631\u0648\u062f\u06cc: \u0633\u0631 = [3,1]\n<p>\u062e\u0631\u0648\u062c\u06cc: [-1,-1]\n<p>\u062a\u0648\u0636\u06cc\u062d: \u0647\u06cc\u0686 \u0646\u0642\u0637\u0647 \u0628\u062d\u0631\u0627\u0646\u06cc \u062f\u0631 \u0622\u0646 \u0648\u062c\u0648\u062f \u0646\u062f\u0627\u0631\u062f [3,1].<\/p>\n<p>\u0645\u062b\u0627\u0644 2:<\/p>\n<p>\u0648\u0631\u0648\u062f\u06cc: \u0633\u0631 = [5,3,1,2,5,1,2]\n<p>\u062e\u0631\u0648\u062c\u06cc: [1,3]\n<p>\u062a\u0648\u0636\u06cc\u062d: \u0633\u0647 \u0646\u06a9\u062a\u0647 \u0645\u0647\u0645 \u0648\u062c\u0648\u062f \u062f\u0627\u0631\u062f:<\/p>\n[5,3,1,2,5,1,2]: \u06af\u0631\u0647 \u0633\u0648\u0645 \u06cc\u06a9 \u062d\u062f\u0627\u0642\u0644 \u0645\u062d\u0644\u06cc \u0627\u0633\u062a \u0632\u06cc\u0631\u0627 1 \u06a9\u0645\u062a\u0631 \u0627\u0632 3 \u0648 2 \u0627\u0633\u062a.<br \/>\n[5,3,1,2,5,1,2]: \u06af\u0631\u0647 \u067e\u0646\u062c\u0645 \u06cc\u06a9 \u0645\u0627\u06a9\u0632\u06cc\u0645\u0645 \u0645\u062d\u0644\u06cc \u0627\u0633\u062a \u0632\u06cc\u0631\u0627 5 \u0628\u0632\u0631\u06af\u062a\u0631 \u0627\u0632 2 \u0648 1 \u0627\u0633\u062a.<br \/>\n[5,3,1,2,5,1,2]: \u06af\u0631\u0647 \u0634\u0634\u0645 \u06cc\u06a9 \u062d\u062f\u0627\u0642\u0644 \u0645\u062d\u0644\u06cc \u0627\u0633\u062a \u0632\u06cc\u0631\u0627 1 \u06a9\u0645\u062a\u0631 \u0627\u0632 5 \u0648 2 \u0627\u0633\u062a.<br \/>\n\u062d\u062f\u0627\u0642\u0644 \u0641\u0627\u0635\u0644\u0647 \u0628\u06cc\u0646 \u06af\u0631\u0647 \u067e\u0646\u062c\u0645 \u0648 \u0634\u0634\u0645 \u0627\u0633\u062a.  MinDistance = 6 &#8211; 5 = 1.<br \/>\n\u062d\u062f\u0627\u06a9\u062b\u0631 \u0641\u0627\u0635\u0644\u0647 \u0628\u06cc\u0646 \u06af\u0631\u0647 \u0633\u0648\u0645 \u0648 \u0634\u0634\u0645 \u0627\u0633\u062a.  \u062d\u062f\u0627\u06a9\u062b\u0631 \u0641\u0627\u0635\u0644\u0647 = 6 &#8211; 3 = 3.<\/p>\n<p>\u0645\u062b\u0627\u0644 3:<\/p>\n<p>\u0648\u0631\u0648\u062f\u06cc: \u0633\u0631 = [1,3,2,2,3,2,2,2,7]\n<p>\u062e\u0631\u0648\u062c\u06cc: [3,3]\n<p>\u062a\u0648\u0636\u06cc\u062d: \u062f\u0648 \u0646\u06a9\u062a\u0647 \u0645\u0647\u0645 \u0648\u062c\u0648\u062f \u062f\u0627\u0631\u062f:<\/p>\n[1,3,2,2,3,2,2,2,7]: \u06af\u0631\u0647 \u062f\u0648\u0645 \u06cc\u06a9 \u0645\u0627\u06a9\u0632\u06cc\u0645\u0645 \u0645\u062d\u0644\u06cc \u0627\u0633\u062a \u0632\u06cc\u0631\u0627 3 \u0628\u0632\u0631\u06af\u062a\u0631 \u0627\u0632 1 \u0648 2 \u0627\u0633\u062a.<br \/>\n[1,3,2,2,3,2,2,2,7]: \u06af\u0631\u0647 \u067e\u0646\u062c\u0645 \u06cc\u06a9 \u0645\u0627\u06a9\u0632\u06cc\u0645\u0645 \u0645\u062d\u0644\u06cc \u0627\u0633\u062a \u0632\u06cc\u0631\u0627 3 \u0628\u0632\u0631\u06af\u062a\u0631 \u0627\u0632 2 \u0648 2 \u0627\u0633\u062a.<br \/>\n\u0647\u0631 \u062f\u0648 \u062d\u062f\u0627\u0642\u0644 \u0648 \u062d\u062f\u0627\u06a9\u062b\u0631 \u0641\u0627\u0635\u0644\u0647 \u0628\u06cc\u0646 \u06af\u0631\u0647 \u062f\u0648\u0645 \u0648 \u067e\u0646\u062c\u0645 \u0627\u0633\u062a.<br \/>\n\u0628\u0646\u0627\u0628\u0631\u0627\u06cc\u0646\u060c minDistance \u0648 maxDistance 5 &#8211; 2 = 3 \u0627\u0633\u062a.<br \/>\n\u062a\u0648\u062c\u0647 \u062f\u0627\u0634\u062a\u0647 \u0628\u0627\u0634\u06cc\u062f \u06a9\u0647 \u0622\u062e\u0631\u06cc\u0646 \u06af\u0631\u0647 \u0628\u0647 \u062f\u0644\u06cc\u0644 \u0646\u062f\u0627\u0634\u062a\u0646 \u06af\u0631\u0647 \u0628\u0639\u062f\u06cc\u060c \u062d\u062f\u0627\u06a9\u062b\u0631 \u0645\u062d\u0644\u06cc \u062f\u0631 \u0646\u0638\u0631 \u06af\u0631\u0641\u062a\u0647 \u0646\u0645\u06cc \u0634\u0648\u062f.<\/p>\n<p>\u0645\u062d\u062f\u0648\u062f\u06cc\u062a \u0647\u0627:<\/p>\n<p>\u062a\u0639\u062f\u0627\u062f \u06af\u0631\u0647 \u0647\u0627 \u062f\u0631 \u0644\u06cc\u0633\u062a \u062f\u0631 \u0645\u062d\u062f\u0648\u062f\u0647 \u0627\u0633\u062a [2, 105].<br \/>\n1 5<\/p>\n<p>\u0631\u0627\u0647 \u062d\u0644:<\/p>\n<p>\/**<br \/>\n * Definition for a singly-linked list.<br \/>\n * class ListNode {<br \/>\n *     public $val = 0;<br \/>\n *     public $next = null;<br \/>\n *     function __construct($val = 0, $next = null) {<br \/>\n *         $this-&gt;val = $val;<br \/>\n *         $this-&gt;next = $next;<br \/>\n *     }<br \/>\n * }<br \/>\n *\/<br \/>\nclass Solution {<\/p>\n<p>    \/**<br \/>\n     * @param ListNode $head<br \/>\n     * @return Integer[]\n     *\/<br \/>\n    function nodesBetweenCriticalPoints($head) {<br \/>\n        $result = [-1, -1];<\/p>\n<p>        \/\/ Initialize minimum distance to the maximum possible value<br \/>\n        $minDistance = PHP_INT_MAX;<\/p>\n<p>        \/\/ Pointers to track the previous node, current node, and indices<br \/>\n        $previousNode = $head;<br \/>\n        $currentNode = $head-&gt;next;<br \/>\n        $currentIndex = 1;<br \/>\n        $previousCriticalIndex = 0;<br \/>\n        $firstCriticalIndex = 0;<\/p>\n<p>        while ($currentNode-&gt;next != null) {<br \/>\n            \/\/ Check if the current node is a local maxima or minima<br \/>\n            if (($currentNode-&gt;val val &amp;&amp;<br \/>\n                    $currentNode-&gt;val next-&gt;val) ||<br \/>\n                ($currentNode-&gt;val &gt; $previousNode-&gt;val &amp;&amp;<br \/>\n                    $currentNode-&gt;val &gt; $currentNode-&gt;next-&gt;val)) {<br \/>\n                \/\/ If this is the first critical point found<br \/>\n                if ($previousCriticalIndex == 0) {<br \/>\n                    $previousCriticalIndex = $currentIndex;<br \/>\n                    $firstCriticalIndex = $currentIndex;<br \/>\n                } else {<br \/>\n                    \/\/ Calculate the minimum distance between critical points<br \/>\n                    $minDistance = min($minDistance, $currentIndex &#8211; $previousCriticalIndex);<br \/>\n                    $previousCriticalIndex = $currentIndex;<br \/>\n                }<br \/>\n            }<\/p>\n<p>            \/\/ Move to the next node and update indices<br \/>\n            $currentIndex++;<br \/>\n            $previousNode = $currentNode;<br \/>\n            $currentNode = $currentNode-&gt;next;<br \/>\n        }<\/p>\n<p>        \/\/ If at least two critical points were found<br \/>\n        if ($minDistance != PHP_INT_MAX) {<br \/>\n            $maxDistance = $previousCriticalIndex &#8211; $firstCriticalIndex;<br \/>\n            $result = [$minDistance, $maxDistance];<br \/>\n        }<\/p>\n<p>        return $result;<br \/>\n    }<br \/>\n}<\/p>\n<p>    \u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/p>\n<p>    \u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/p>\n<div data-article-id=\"1913039\" id=\"article-body\">\n<p>2058. \u062d\u062f\u0627\u0642\u0644 \u0648 \u062d\u062f\u0627\u06a9\u062b\u0631 \u062a\u0639\u062f\u0627\u062f \u06af\u0631\u0647 \u0647\u0627 \u0631\u0627 \u0628\u06cc\u0646 \u0646\u0642\u0627\u0637 \u0628\u062d\u0631\u0627\u0646\u06cc \u0628\u06cc\u0627\u0628\u06cc\u062f.<\/p>\n<p>\u0645\u062a\u0648\u0633\u0637<\/p>\n<p>\u0622 <strong>\u0646\u0642\u0637\u0647 \u0628\u062d\u0631\u0627\u0646\u06cc<\/strong> \u062f\u0631 \u06cc\u06a9 \u0644\u06cc\u0633\u062a \u067e\u06cc\u0648\u0646\u062f\u06cc \u0628\u0647 \u0639\u0646\u0648\u0627\u0646 \u062a\u0639\u0631\u06cc\u0641 \u0645\u06cc \u0634\u0648\u062f <strong>\u06cc\u0627<\/strong> \u0622 <strong>\u062d\u062f\u0627\u06a9\u062b\u0631 \u0645\u062d\u0644\u06cc<\/strong> \u06cc\u0627 \u0627\u0644\u0641 <strong>\u062d\u062f\u0627\u0642\u0644 \u0647\u0627\u06cc \u0645\u062d\u0644\u06cc<\/strong>.<\/p>\n<p>\u06cc\u06a9 \u06af\u0631\u0647 \u06cc\u06a9 \u0627\u0633\u062a <strong>\u062d\u062f\u0627\u06a9\u062b\u0631 \u0645\u062d\u0644\u06cc<\/strong> \u0627\u06af\u0631 \u06af\u0631\u0647 \u0641\u0639\u0644\u06cc \u06cc\u06a9 \u0645\u0642\u062f\u0627\u0631 \u062f\u0627\u0634\u062a\u0647 \u0628\u0627\u0634\u062f <strong>\u0628\u0647 \u0634\u062f\u062a \u0628\u0632\u0631\u06af\u062a\u0631<\/strong> \u0646\u0633\u0628\u062a \u0628\u0647 \u06af\u0631\u0647 \u0642\u0628\u0644\u06cc \u0648 \u06af\u0631\u0647 \u0628\u0639\u062f\u06cc.<\/p>\n<p>\u06cc\u06a9 \u06af\u0631\u0647 \u06cc\u06a9 \u0627\u0633\u062a <strong>\u062d\u062f\u0627\u0642\u0644 \u0647\u0627\u06cc \u0645\u062d\u0644\u06cc<\/strong> \u0627\u06af\u0631 \u06af\u0631\u0647 \u0641\u0639\u0644\u06cc \u06cc\u06a9 \u0645\u0642\u062f\u0627\u0631 \u062f\u0627\u0634\u062a\u0647 \u0628\u0627\u0634\u062f <strong>\u0628\u0647 \u0634\u062f\u062a \u06a9\u0648\u0686\u06a9\u062a\u0631<\/strong> \u0646\u0633\u0628\u062a \u0628\u0647 \u06af\u0631\u0647 \u0642\u0628\u0644\u06cc \u0648 \u06af\u0631\u0647 \u0628\u0639\u062f\u06cc.<\/p>\n<p>\u062a\u0648\u062c\u0647 \u062f\u0627\u0634\u062a\u0647 \u0628\u0627\u0634\u06cc\u062f \u06a9\u0647 \u06cc\u06a9 \u06af\u0631\u0647 \u062a\u0646\u0647\u0627 \u062f\u0631 \u0635\u0648\u0631\u062a \u0648\u062c\u0648\u062f \u0645\u06cc \u062a\u0648\u0627\u0646\u062f \u062d\u062f\u0627\u06a9\u062b\u0631\/\u062d\u062f\u0627\u0642\u0644 \u0645\u062d\u0644\u06cc \u0628\u0627\u0634\u062f <strong>\u0647\u0631 \u062f\u0648<\/strong> \u06cc\u06a9 \u06af\u0631\u0647 \u0642\u0628\u0644\u06cc \u0648 \u06cc\u06a9 \u06af\u0631\u0647 \u0628\u0639\u062f\u06cc.<\/p>\n<p>\u0628\u0627 \u062a\u0648\u062c\u0647 \u0628\u0647 \u06cc\u06a9 \u0644\u06cc\u0633\u062a \u067e\u06cc\u0648\u0646\u062f\u06cc <code>head<\/code>\u060c \u0628\u0631\u06af\u0634\u062a <em>\u0622\u0631\u0627\u06cc\u0647 \u0627\u06cc \u0628\u0647 \u0637\u0648\u0644 2 \u0634\u0627\u0645\u0644 <code>[minDistance, maxDistance]<\/code> \u062c\u0627\u06cc\u06cc \u06a9\u0647 <code>minDistance<\/code> \u0647\u0633\u062a <strong>\u062d\u062f\u0627\u0642\u0644 \u0641\u0627\u0635\u0644\u0647<\/strong> \u0628\u06cc\u0646 <strong>\u0647\u0631 \u062f\u0648 \u0645\u062a\u0645\u0627\u06cc\u0632<\/strong> \u0646\u0642\u0627\u0637 \u0628\u062d\u0631\u0627\u0646\u06cc \u0648 <code>maxDistance<\/code> \u0647\u0633\u062a <strong>\u062d\u062f\u0627\u06a9\u062b\u0631 \u0641\u0627\u0635\u0644\u0647<\/strong> \u0628\u06cc\u0646 <strong>\u0647\u0631 \u062f\u0648 \u0645\u062a\u0645\u0627\u06cc\u0632<\/strong> \u0646\u0642\u0627\u0637 \u0628\u062d\u0631\u0627\u0646\u06cc.  \u0627\u06af\u0631 \u0648\u062c\u0648\u062f \u062f\u0627\u0631\u062f <strong>\u06a9\u0645\u062a\u0631<\/strong> \u0627\u0632 \u062f\u0648 \u0646\u0642\u0637\u0647 \u0628\u062d\u0631\u0627\u0646\u06cc\u060c \u0628\u0627\u0632\u06af\u0634\u062a <code>[-1, -1]<\/code><\/em>.<\/p>\n<p><strong>\u0645\u062b\u0627\u0644 1:<\/strong><\/p>\n<p><\/p>\n<ul>\n<li>\n<strong>\u0648\u0631\u0648\u062f\u06cc:<\/strong> \u0633\u0631 = [3,1]<\/li>\n<li>\n<strong>\u062e\u0631\u0648\u062c\u06cc:<\/strong> [-1,-1]<\/li>\n<li>\n<strong>\u062a\u0648\u0636\u06cc\u062d:<\/strong> \u0647\u06cc\u0686 \u0646\u0642\u0637\u0647 \u0628\u062d\u0631\u0627\u0646\u06cc \u062f\u0631 \u0622\u0646 \u0648\u062c\u0648\u062f \u0646\u062f\u0627\u0631\u062f [3,1].<\/li>\n<\/ul>\n<p><strong>\u0645\u062b\u0627\u0644 2:<\/strong><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/practicaldev\/image\/fetch\/s--Xa0E9EcA--\/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800\/https:\/\/assets.leetcode.com\/uploads\/2021\/10\/13\/a2.png\" alt=\"a2\" loading=\"lazy\" width=\"624\" height=\"46\" title=\"\"><\/p>\n<ul>\n<li>\n<strong>\u0648\u0631\u0648\u062f\u06cc:<\/strong> \u0633\u0631 = [5,3,1,2,5,1,2]<\/li>\n<li>\n<strong>\u062e\u0631\u0648\u062c\u06cc:<\/strong> [1,3]<\/li>\n<li>\n<strong>\u062a\u0648\u0636\u06cc\u062d:<\/strong> \u0633\u0647 \u0646\u06a9\u062a\u0647 \u0645\u0647\u0645 \u0648\u062c\u0648\u062f \u062f\u0627\u0631\u062f:<\/p>\n<ul>\n<li>[5,3,1,2,5,1,2]: \u06af\u0631\u0647 \u0633\u0648\u0645 \u06cc\u06a9 \u062d\u062f\u0627\u0642\u0644 \u0645\u062d\u0644\u06cc \u0627\u0633\u062a \u0632\u06cc\u0631\u0627 1 \u06a9\u0645\u062a\u0631 \u0627\u0632 3 \u0648 2 \u0627\u0633\u062a.<\/li>\n<li>[5,3,1,2,5,1,2]: \u06af\u0631\u0647 \u067e\u0646\u062c\u0645 \u06cc\u06a9 \u0645\u0627\u06a9\u0632\u06cc\u0645\u0645 \u0645\u062d\u0644\u06cc \u0627\u0633\u062a \u0632\u06cc\u0631\u0627 5 \u0628\u0632\u0631\u06af\u062a\u0631 \u0627\u0632 2 \u0648 1 \u0627\u0633\u062a.<\/li>\n<li>[5,3,1,2,5,1,2]: \u06af\u0631\u0647 \u0634\u0634\u0645 \u06cc\u06a9 \u062d\u062f\u0627\u0642\u0644 \u0645\u062d\u0644\u06cc \u0627\u0633\u062a \u0632\u06cc\u0631\u0627 1 \u06a9\u0645\u062a\u0631 \u0627\u0632 5 \u0648 2 \u0627\u0633\u062a.<\/li>\n<li>\u062d\u062f\u0627\u0642\u0644 \u0641\u0627\u0635\u0644\u0647 \u0628\u06cc\u0646 \u06af\u0631\u0647 \u067e\u0646\u062c\u0645 \u0648 \u0634\u0634\u0645 \u0627\u0633\u062a.  MinDistance = 6 &#8211; 5 = 1.<\/li>\n<li>\u062d\u062f\u0627\u06a9\u062b\u0631 \u0641\u0627\u0635\u0644\u0647 \u0628\u06cc\u0646 \u06af\u0631\u0647 \u0633\u0648\u0645 \u0648 \u0634\u0634\u0645 \u0627\u0633\u062a.  \u062d\u062f\u0627\u06a9\u062b\u0631 \u0641\u0627\u0635\u0644\u0647 = 6 &#8211; 3 = 3.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><strong>\u0645\u062b\u0627\u0644 3:<\/strong><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/practicaldev\/image\/fetch\/s--LeSG0o4U--\/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800\/https:\/\/assets.leetcode.com\/uploads\/2021\/10\/14\/a5.png\" alt=\"a5\" loading=\"lazy\" width=\"624\" height=\"39\" title=\"\"><\/p>\n<ul>\n<li>\n<strong>\u0648\u0631\u0648\u062f\u06cc:<\/strong> \u0633\u0631 = [1,3,2,2,3,2,2,2,7]<\/li>\n<li>\n<strong>\u062e\u0631\u0648\u062c\u06cc:<\/strong> [3,3]<\/li>\n<li>\n<strong>\u062a\u0648\u0636\u06cc\u062d:<\/strong> \u062f\u0648 \u0646\u06a9\u062a\u0647 \u0645\u0647\u0645 \u0648\u062c\u0648\u062f \u062f\u0627\u0631\u062f:<\/p>\n<ul>\n<li>[1,3,2,2,3,2,2,2,7]: \u06af\u0631\u0647 \u062f\u0648\u0645 \u06cc\u06a9 \u0645\u0627\u06a9\u0632\u06cc\u0645\u0645 \u0645\u062d\u0644\u06cc \u0627\u0633\u062a \u0632\u06cc\u0631\u0627 3 \u0628\u0632\u0631\u06af\u062a\u0631 \u0627\u0632 1 \u0648 2 \u0627\u0633\u062a.<\/li>\n<li>[1,3,2,2,3,2,2,2,7]: \u06af\u0631\u0647 \u067e\u0646\u062c\u0645 \u06cc\u06a9 \u0645\u0627\u06a9\u0632\u06cc\u0645\u0645 \u0645\u062d\u0644\u06cc \u0627\u0633\u062a \u0632\u06cc\u0631\u0627 3 \u0628\u0632\u0631\u06af\u062a\u0631 \u0627\u0632 2 \u0648 2 \u0627\u0633\u062a.<\/li>\n<li>\u0647\u0631 \u062f\u0648 \u062d\u062f\u0627\u0642\u0644 \u0648 \u062d\u062f\u0627\u06a9\u062b\u0631 \u0641\u0627\u0635\u0644\u0647 \u0628\u06cc\u0646 \u06af\u0631\u0647 \u062f\u0648\u0645 \u0648 \u067e\u0646\u062c\u0645 \u0627\u0633\u062a.<\/li>\n<li>\u0628\u0646\u0627\u0628\u0631\u0627\u06cc\u0646\u060c minDistance \u0648 maxDistance 5 &#8211; 2 = 3 \u0627\u0633\u062a.<\/li>\n<li>\u062a\u0648\u062c\u0647 \u062f\u0627\u0634\u062a\u0647 \u0628\u0627\u0634\u06cc\u062f \u06a9\u0647 \u0622\u062e\u0631\u06cc\u0646 \u06af\u0631\u0647 \u0628\u0647 \u062f\u0644\u06cc\u0644 \u0646\u062f\u0627\u0634\u062a\u0646 \u06af\u0631\u0647 \u0628\u0639\u062f\u06cc\u060c \u062d\u062f\u0627\u06a9\u062b\u0631 \u0645\u062d\u0644\u06cc \u062f\u0631 \u0646\u0638\u0631 \u06af\u0631\u0641\u062a\u0647 \u0646\u0645\u06cc \u0634\u0648\u062f.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><strong>\u0645\u062d\u062f\u0648\u062f\u06cc\u062a \u0647\u0627:<\/strong><\/p>\n<ul>\n<li>\u062a\u0639\u062f\u0627\u062f \u06af\u0631\u0647 \u0647\u0627 \u062f\u0631 \u0644\u06cc\u0633\u062a \u062f\u0631 \u0645\u062d\u062f\u0648\u062f\u0647 \u0627\u0633\u062a <code>[2, 10<sup>5<\/sup>]<\/code>.<\/li>\n<li><code>1 5<\/code><\/li>\n<\/ul>\n<p><strong>\u0631\u0627\u0647 \u062d\u0644:<\/strong><\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>\/**\n * Definition for a singly-linked list.\n * class ListNode {\n *     public $val = 0;\n *     public $next = null;\n *     function __construct($val = 0, $next = null) {\n *         $this-&gt;val = $val;\n *         $this-&gt;next = $next;\n *     }\n * }\n *\/\nclass Solution {\n\n    \/**\n     * @param ListNode $head\n     * @return Integer[]\n     *\/\n    function nodesBetweenCriticalPoints($head) {\n        $result = [-1, -1];\n\n        \/\/ Initialize minimum distance to the maximum possible value\n        $minDistance = PHP_INT_MAX;\n\n        \/\/ Pointers to track the previous node, current node, and indices\n        $previousNode = $head;\n        $currentNode = $head-&gt;next;\n        $currentIndex = 1;\n        $previousCriticalIndex = 0;\n        $firstCriticalIndex = 0;\n\n        while ($currentNode-&gt;next != null) {\n            \/\/ Check if the current node is a local maxima or minima\n            if (($currentNode-&gt;val val &amp;&amp;\n                    $currentNode-&gt;val next-&gt;val) ||\n                ($currentNode-&gt;val &gt; $previousNode-&gt;val &amp;&amp;\n                    $currentNode-&gt;val &gt; $currentNode-&gt;next-&gt;val)) {\n                \/\/ If this is the first critical point found\n                if ($previousCriticalIndex == 0) {\n                    $previousCriticalIndex = $currentIndex;\n                    $firstCriticalIndex = $currentIndex;\n                } else {\n                    \/\/ Calculate the minimum distance between critical points\n                    $minDistance = min($minDistance, $currentIndex - $previousCriticalIndex);\n                    $previousCriticalIndex = $currentIndex;\n                }\n            }\n\n            \/\/ Move to the next node and update indices\n            $currentIndex++;\n            $previousNode = $currentNode;\n            $currentNode = $currentNode-&gt;next;\n        }\n\n        \/\/ If at least two critical points were found\n        if ($minDistance != PHP_INT_MAX) {\n            $maxDistance = $previousCriticalIndex - $firstCriticalIndex;\n            $result = [$minDistance, $maxDistance];\n        }\n\n        return $result;\n    }\n}\n<\/code><\/pre>\n<div class=\"highlight__panel js-actions-panel\">\n<div class=\"highlight__panel-action js-fullscreen-code-action\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\"><title>\u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\"\/>\n<\/svg><\/p>\n<p>    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\"><title>\u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\"\/>\n<\/svg><\/p>\n<\/div>\n<\/div>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Summarize this content to 400 words in Persian Lang 2058. \u062d\u062f\u0627\u0642\u0644 \u0648 \u062d\u062f\u0627\u06a9\u062b\u0631 \u062a\u0639\u062f\u0627\u062f \u06af\u0631\u0647 \u0647\u0627 \u0631\u0627 \u0628\u06cc\u0646 \u0646\u0642\u0627\u0637 \u0628\u062d\u0631\u0627\u0646\u06cc \u0628\u06cc\u0627\u0628\u06cc\u062f. \u0645\u062a\u0648\u0633\u0637 \u0622 \u0646\u0642\u0637\u0647 \u0628\u062d\u0631\u0627\u0646\u06cc \u062f\u0631 \u06cc\u06a9 \u0644\u06cc\u0633\u062a \u067e\u06cc\u0648\u0646\u062f\u06cc \u0628\u0647 \u0639\u0646\u0648\u0627\u0646 \u062a\u0639\u0631\u06cc\u0641 \u0645\u06cc \u0634\u0648\u062f \u06cc\u0627 \u0622 \u062d\u062f\u0627\u06a9\u062b\u0631 \u0645\u062d\u0644\u06cc \u06cc\u0627 \u0627\u0644\u0641 \u062d\u062f\u0627\u0642\u0644 \u0647\u0627\u06cc \u0645\u062d\u0644\u06cc. \u06cc\u06a9 \u06af\u0631\u0647 \u06cc\u06a9 \u0627\u0633\u062a \u062d\u062f\u0627\u06a9\u062b\u0631 \u0645\u062d\u0644\u06cc \u0627\u06af\u0631 \u06af\u0631\u0647 \u0641\u0639\u0644\u06cc \u06cc\u06a9 \u0645\u0642\u062f\u0627\u0631 \u062f\u0627\u0634\u062a\u0647 &hellip;<\/p>\n","protected":false},"author":2,"featured_media":68280,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"","fifu_image_alt":"","footnotes":""},"categories":[339],"tags":[],"class_list":["post-68279","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dev"],"_links":{"self":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/posts\/68279","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/comments?post=68279"}],"version-history":[{"count":0,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/posts\/68279\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/media\/68280"}],"wp:attachment":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/media?parent=68279"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/categories?post=68279"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/tags?post=68279"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}