220v
젝무의 개발새발
220v
전체 방문자
오늘
어제
  • 분류 전체보기 (255)
    • AI (35)
      • ML, DL 학습 (30)
      • 논문 리뷰 (4)
      • 실습 및 프로젝트 (1)
    • Algorithm (145)
      • LeetCode (13)
      • 프로그래머스 (35)
      • 백준 (96)
      • 알고리즘, 문법 정리 (1)
    • Mobile, Application (17)
      • Flutter (10)
      • iOS, MacOS (7)
    • BackEnd (7)
      • Flask (1)
      • Node.js (5)
      • Spring, JSP..etc (1)
    • Web - FrontEnd (18)
      • JavaScript, JQuery, HTML, C.. (12)
      • React (6)
    • DataBase (1)
      • MySQL (1)
      • Firebase Firestore (0)
      • Supabase (0)
    • Git (1)
    • 기타 툴 및 오류 해결 (3)
    • 강의 (5)
      • Database (3)
      • 암호학 (2)
      • 알고리즘 (0)
    • 후기와 회고 (2)
    • 블로그 꾸미기 (1)
    • 일상과 이것저것 (20)
      • 맛집 (12)
      • 세상사는일 (4)
      • 도서리뷰 (1)
      • 이런저런 생각들 (잡글) (3)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

인기 글

태그

  • 프로그래머스
  • BFS
  • Mathematics
  • Lis
  • top-down
  • Minimum Spanning Tree
  • dp
  • Backtracking
  • brute-Force
  • Dynamic Programming
  • 백준
  • topological sort
  • REACT
  • Prefix Sum
  • two pointer
  • 티스토리챌린지
  • Greedy
  • 오블완
  • IMPLEMENT
  • simulation
  • implementation
  • 다익스트라
  • union-find
  • binary search
  • dfs
  • 위상 정렬
  • disjoint set
  • Priority Queue
  • 구현
  • bitmasking

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
220v

젝무의 개발새발

Algorithm/LeetCode

[LeetCode/릿코드] 1710. Maximum Units on a Truck (220701 daily challenge)

2022. 7. 5. 06:10

간단해서 설명할 게 없음

class Solution:
    def maximumUnits(self, boxTypes: List[List[int]], truckSize: int) -> int:
        sumOfUnits = 0

        boxList = sorted(boxTypes, key=lambda x: x[1], reverse=True)

        for i in boxList:
            if truckSize >= i[0]:
                truckSize -= i[0]
                sumOfUnits += i[0] * i[1]

            elif truckSize > 0 and truckSize < i[0]:
                sumOfUnits += i[1] * truckSize
                truckSize = -1

            else:
                break
        
        return sumOfUnits
    'Algorithm/LeetCode' 카테고리의 다른 글
    • [LeetCode] 509. Fibonacci Number
    • [LeetCode/릿코드] 128. Longest Consecutive Sequence (220705 daily challenge)
    • [LeetCode/릿코드] 376. Wiggle Subsequence (220703 daily challenge)
    • [LeetCode/릿코드] 135. Candy (220704 daily challenge)
    220v
    220v
    DGU CSE 20 / Apple Developer Academy @ POSTECH 2nd Jr.Learner.

    티스토리툴바