Back to course home
0% completed
Vote For New Content
Go solution. Is this really easy problem?
fellainthewagon
Jul 13, 2024
After reading description the very first thing that came to me is that really easy problem? Then I checked on leetcode and it's medium there.
type Solution struct{} func (s *Solution) removeNodes(head *ListNode) *ListNode { dummy := &ListNode{} dummy.Next = head curr := dummy.Next stack := []*ListNode{} stack = append(stack, dummy) for curr != nil && curr.Next != nil { next := curr.Next for len(stack) != 0 && curr.Val < next.Val { prev := stack[len(stack)-1] stack = stack[:len(stack)-1] prev.Next = next curr = prev } stack = append(stack, curr) curr = next } return dummy.Next }
0
0
Comments
Comments
L
lejafilip a year ago
It is not easy problem. It is medium here and on LC.