PageSourceSearch

https://codemia.io/_next/static/chunks/7875.39fdb870130486a8.js

js codemia.io collected 2026-10-02 04:27:44 UTC 10,562 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7875],{397:function(e,t,n){var r=n(1119),s=n(74610),i=n(2265),a=n(52836),o=n(31691),p=n(31090),c=n(60118),l=n(57437);let u=["addEndListener","appear","children","easing","in","onEnter","onEntered","onEntering","onExit","onExited","onExiting","style","timeout","TransitionComponent"],d={entering:{transform:"none"},entered:{transform:"none"}},h=i.forwardRef(function(e,t){let n=(0,o.Z)(),h={enter:n.transitions.duration.enteringScreen,exit:n.transitions.duration.leavingScreen},{addEndListener:m,appear:x=!0,children:f,easing:k,in:y,onEnter:g,onEntered:b,onEntering:j,onExit:w,onExited:Z,onExiting:S,style:v,timeout:T=h,TransitionComponent:E=a.ZP}=e,I=(0,s.Z)(e,u),_=i.useRef(null),C=(0,c.Z)(_,f.ref,t),D=e=>t=>{if(e){let n=_.current;void 0===t?e(n):e(n,t)}},W=D(j),L=D((e,t)=>{(0,p.n)(e);let r=(0,p.C)({style:v,timeout:T,easing:k},{mode:"enter"});e.style.webkitTransition=n.transitions.create("transform",r),e.style.transition=n.transitions.create("transform",r),g&&g(e,t)}),P=D(b),R=D(S),q=D(e=>{let t=(0,p.C)({style:v,timeout:T,easing:k},{mode:"exit"});e.style.webkitTransition=n.transitions.create("transform",t),e.style.transition=n.transitions.create("transform",t),w&&w(e)}),z=D(Z);return(0,l.jsx)(E,(0,r.Z)({appear:x,in:y,nodeRef:_,onEnter:L,onEntered:P,onEntering:W,onExit:q,onExited:z,onExiting:R,addEndListener:e=>{m&&m(_.current,e)},timeout:T},I,{children:(e,t)=>i.cloneElement(f,(0,r.Z)({style:(0,r.Z)({transform:"scale(0)",visibility:"exited"!==e||y?void 0:"hidden"},d[e],v,f.props.style),ref:C},t))}))});t.Z=h},20915:function(e,t,n){n.d(t,{X:function(){return p}});var r=n(57437);n(2265);var s=n(63832),i=n(46387),a=n(19902),o=n(397);let p=e=>{let{frame:t}=e,{input:n,stack:p,output:c,i:l,message:u}=t.state;return(0,r.jsxs)(s.Z,{sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:6,p:4,width:"100%",height:"100%"},children:[(0,r.jsx)(s.Z,{sx:{height:40},children:u&&(0,r.jsx)(i.Z,{color:"#a1a1aa",children:u})}),(0,r.jsxs)(s.Z,{sx:{display:"flex",flexDirection:"column",gap:1},children:[(0,r.jsx)(i.Z,{variant:"caption",color:"#a1a1aa",children:"Input"}),(0,r.jsx)(s.Z,{sx:{display:"flex",gap:1},children:n.map((e,t)=>(0,r.jsx)(a.Z,{sx:{width:40,height:40,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:t===l?"#3b82f6":"#27272a",border:"1px solid ".concat(t===l?"#60a5fa":"#3f3f46"),color:"#fff"},children:(0,r.jsx)(i.Z,{fontWeight:"bold",children:e})},t))})]}),(0,r.jsxs)(s.Z,{sx:{display:"flex",gap:8,alignItems:"flex-start"},children:[(0,r.jsxs)(s.Z,{sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:1},children:[(0,r.jsx)(i.Z,{variant:"caption",color:"#a1a1aa",children:"Stack (Indices)"}),(0,r.jsx)(s.Z,{sx:{width:60,minHeight:200,border:"2px solid #3f3f46",borderTop:"none",borderRadius:"0 0 8px 8px",bgcolor:"#18181b",display:"flex",flexDirection:"column-reverse",p:1,gap:1},children:p.map((e,t)=>(0,r.jsx)(o.Z,{in:!0,children:(0,r.jsx)(a.Z,{sx:{width:"100%",height:30,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"#8b5cf6",color:"#fff"},children:(0,r.jsx)(i.Z,{fontSize:"12px",children:e})})},t))})]}),c&&(0,r.jsxs)(s.Z,{sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:1},children:[(0,r.jsx)(i.Z,{variant:"caption",color:"#a1a1aa",children:"Output"}),(0,r.jsx)(s.Z,{sx:{display:"flex",gap:1},children:c.map((e,t)=>(0,r.jsx)(a.Z,{sx:{width:40,height:40,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"#18181b",border:"1px solid #3f3f46",color:0!==e?"#22c55e":"#71717a"},children:(0,r.jsx)(i.Z,{fontWeight:"bold",children:e})},t))})]})]})]})}},7875:function(e,t,n){n.r(t),n.d(t,{DailyTemperatures:function(){return r}});let r={id:"daily-temperatures",label:"Daily Temperatures",description:"Given an array of integers temperatures represents the daily temperatures, return an array answer such that answer[i] is the number of days you have to wait after the ith day to get a warmer temperature. If there is no future day for which this is possible, keep answer[i] == 0.",constraints:["$1 \\leq \\text{temperatures.length} \\leq 10^5$","$30 \\leq \\text{temperatures}[i] \\leq 100$"],topics:["array","stack","monotonic-stack"],companies:["Amazon","Facebook","Google","Microsoft"],category:"Stack",difficulty:"Medium",code:{python:"class Solution:\n    def dailyTemperatures(self, temperatures: List[int]) -> List[int]:\n        res = [0] * len(temperatures)\n        stack = []  # pair: [temp, index]\n        \n        for i, t in enumerate(temperatures):\n            while stack and t > stack[-1][0]:\n                stackT, stackInd = stack.pop()\n                res[stackInd] = i 
1- stackInd\n            stack.append((t, i))\n        return res",javascript:"function dailyTemperatures(temperatures) {\n    const res = new Array(temperatures.length).fill(0);\n    const stack = []; // [index] - stores indices, lookup temp by index\n    \n    for (let i = 0; i < temperatures.length; i++) {\n        while (stack.length > 0 && temperatures[i] > temperatures[stack[stack.length - 1]]) {\n            const index = stack.pop();\n            res[index] = i - index;\n        }\n        stack.push(i);\n    }\n    return res;\n}",typescript:"function dailyTemperatures(temperatures: number[]): number[] {\n    const res = new Array(temperatures.length).fill(0);\n    const stack: number[] = []; // [index]\n    \n    for (let i = 0; i < temperatures.length; i++) {\n        while (stack.length > 0 && temperatures[i] > temperatures[stack[stack.length - 1]]) {\n            const index = stack.pop()!;\n            res[index] = i - index;\n        }\n        stack.push(i);\n    }\n    return res;\n}",java:"class Solution {\n    public int[] dailyTemperatures(int[] temperatures) {\n        int[] res = new int[temperatures.length];\n        Stack<Integer> stack = new Stack<>(); // index\n        \n        for (int i = 0; i < temperatures.length; i++) {\n            while (!stack.isEmpty() && temperatures[i] > temperatures[stack.peek()]) {\n                int index = stack.pop();\n                res[index] = i - index;\n            }\n            stack.push(i);\n        }\n        return res;\n    }\n}",cpp:"class Solution {\npublic:\n    vector<int> dailyTemperatures(vector<int>& temperatures) {\n        vector<int> res(temperatures.size(), 0);\n        stack<int> stack; // index\n        \n        for (int i = 0; i < temperatures.size(); ++i) {\n            while (!stack.empty() && temperatures[i] > temperatures[stack.top()]) {\n                int index = stack.top();\n                stack.pop();\n                res[index] = i - index;\n            }\n            stack.push(i);\n        }\n        return res;\n    }\n};",csharp:"public class Solution {\n    public int[] DailyTemperatures(int[] temperatures) {\n        int[] res = new int[temperatures.Length];\n        Stack<int> stack = new Stack<int>(); // index\n        \n        for (int i = 0; i < temperatures.Length; i++) {\n            while (stack.Count > 0 && temperatures[i] > temperatures[stack.Peek()]) {\n                int index = stack.Pop();\n                res[index] = i - index;\n            }\n            stack.Push(i);\n        }\n        return res;\n    }\n}",go:"func dailyTemperatures(temperatures []int) []int {\n    res := make([]int, len(temperatures))\n    stack := []int{} // index\n    \n    for i, t := range temperatures {\n        for len(stack) > 0 && t > temperatures[stack[len(stack)-1]] {\n            index := stack[len(stack)-1]\n            stack = stack[:len(stack)-1]\n            res[index] = i - index\n        }\n        stack = append(stack, i)\n    }\n    return res\n}"},lineMapping:{python:{init:3,loop:6,check_stack:7,pop:8,update_res:9,push:10,done:11,Start:3},javascript:{init:2,loop:5,check_stack:6,pop:7,update_res:8,push:10,done:12,Start:2},typescript:{init:2,loop:5,check_stack:6,pop:7,update_res:8,push:10,done:12,Start:2},java:{init:3,loop:6,check_stack:7,pop:8,update_res:9,push:11,done:13,Start:3},cpp:{init:4,loop:7,check_stack:8,pop:9,update_res:11,push:13,done:15,Start:4},csharp:{init:3,loop:6,check_stack:7,pop:8,update_res:9,push:11,done:13,Start:3},go:{init:2,loop:5,check_stack:6,pop:7,update_res:9,push:11,done:13,Start:2}},presets:[{label:"Example 1",data:[73,74,75,71,69,72,76,73],expected:"[1,1,4,2,1,1,0,0]"},{label:"Example 2",data:[30,40,50,60],expected:"[1,1,1,0]"},{label:"Example 3",data:[30,60,90],expected:"[1,1,0]"}],defaultInput:[73,74,75,71,69,72,76,73],defaultExpected:"[1,1,4,2,1,1,0,0]",Renderer:n(20915).X,functionSignature:{name:"dailyTemperatures",params:[{name:"temperatures",type:"int[]"}],returnType:"int[]"},starterCode:{python:"class Solution:\n    def dailyTemperatures(self, temperatures: List[int]) -> List[int]:\n        # Write your solution here\n        return []",javascript:"/**\n * @param {number[]} temperatures\n * @return {number[]}\n */\nvar dailyTemperatures = function(temperatures) {\n    // Write your solution here\n    return [];\n};",typescript:"function dailyTemperatures(temperatures: number[]): number[] {\n    // Write your solution here\n    return [];\n}",java:"class Solution {\n    public int[] dailyTemperatures(int[] temperatures) {\n        // Write your solution here\n        return new int[0];\n    }\n}",cpp:"class Solution {\npublic:\n    vector<int> dailyTemperatures(vector<int>& temperatures) {\n        // Write your solution here\n        return {};\n    }\n};",csharp:"public class Solution {\n    public int[] DailyTemperatures(int[] temperatures) {\n        // Write your solution here\n        return new int[0];\n    }\n}",go:"func dailyTemperatures(temperatures []int) []int {\n    // Write your solution here\n    return []int{}\n}"},generateFrames:e=>{let t=[],n=Array(e.length).fill(0),r=[],s=(t,s)=>({input:e,stack:[...r],output:[...n],i:s,message:t});t.push({stepId:"init",line:1,state:s("Start",-1)});for(let i=0;i<e.length;i++){for(t.push({stepId:"loop",line:2,state:s("Process day ".concat(i," (Temp ").concat(e[i],")"),i)}),t.push({stepId:"check_stack",line:3,state:s("Check stack for colder days",i)});r.length>0&&e[i]>e[r[r.length-1]];){let a=r.pop();n[a]=i-a,t.push({stepId:"pop",line:4,state:s("Warmer! Pop day ".concat(a," (").concat(e[a],")."),i)}),t.push({stepId:"update_res",line:5,state:s("Update res[".concat(a,"] = ").concat(i," - ").concat(a," = ").concat(n[a]),i)})}r.push(i),t.push({stepId:"push",line:6,state:s("Push day ".concat(i),i)})}return t.push({stepId:"done",line:7,state:s("Done",e.length)}),t}}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.