Post

leetcode(리트코드)-1913 Maximum Product Difference Between Two Pairs(python)

leetcode 1913 - Maximum Product Difference Between Two Pairs 문제입니다.

1. 문제

https://leetcode.com/problems/maximum-product-difference-between-two-pairs/


2. Input , Output


3. 분류 및 난이도

Eazy 난이도 문제입니다.


4. 문제 해석

  • 리스트의 (a,b,c,d)를 뽑아서 (c * d) - (a * b)의 값이 최대치가 되는 값을 리턴하세요.
  • 정렬해서 하면 참 쉽겠죠?

5. code

코드설명

python

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class Solution:
    def removeDuplicates(self, s: str) -> str:
        res = ""
        st  = deque()
        for i in range(len(s)):
            if st :
                if st[-1] == s[i] : 
                    st.pop()
                else : 
                    st.append(s[i])
            else : 
                st.append(s[i])
        while st : 
            res+=st.popleft()
        return res
            
            

6. 결과 및 후기, 개선점

필요시 c++로 짜드리겠습니다.

This post is licensed under CC BY 4.0 by the author.