My Software Engineering

My Software Engineering

  • 분류 전체보기 (94)
    • Leetcode (93)
  • 홈
  • Leetcode
RSS 피드
로그인
로그아웃 글쓰기 관리

My Software Engineering

컨텐츠 검색

태그

최근글

댓글

공지사항

아카이브

Leetcode(93)

  • 994. Rotting Oranges

    Description: You are given an m x n grid where each cell can have one of three values: 0 representing an empty cell, 1 representing a fresh orange, or 2 representing a rotten orange. Every minute, any fresh orange that is 4-directionally adjacent to a rotten orange becomes rotten. Return the minimum number of minutes that must elapse until no cell has a fresh orange. If this is impossible, retur..

    2021.10.30
  • 121. Best Time to Buy and Sell Stock

    Description: You are given an array prices where prices[i] is the price of a given stock on the ith day. You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock. Return the maximum profit you can achieve from this transaction. If you cannot achieve any profit, return 0. ''' [1] brute force - Time Limit Exceeded) cod..

    2021.10.29
  • 217. Contains Duplicate

    Description: Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct. ''' [1] sorting) code:: def containsDuplicate(nums): nums.sort() for i in range(len(nums)-1): if nums[i]==nums[i+1]: return True return False -T/C: O(nlogn) -S/C: O(1) ''' ''' [2] hashmap) code:: def containsDuplicate(nums): counter={} for num in ..

    2021.10.29
  • 222. Count Complete Tree Nodes

    Description: Given the root of a complete binary tree, return the number of the nodes in the tree. According to Wikipedia, every level, except possibly the last, is completely filled in a complete binary tree, and all nodes in the last level are as far left as possible. It can have between 1 and 2h nodes inclusive at the last level h. Design an algorithm that runs in less than O(n) time complexi..

    2021.10.28
  • 1. Two Sum

    Description: Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order. ''' [1] brute force) code:: for i in range(len(nums)): for j in range(i+1,len(nums)): if nums[i]+nums[j]==target: r..

    2021.10.28
  • 153. Find Minimum in Rotated Sorted Array

    Description: Suppose an array of length n sorted in ascending order is rotated between 1 and n times. For example, the array nums = [0,1,2,4,5,6,7] might become: [4,5,6,7,0,1,2] if it was rotated 4 times. [0,1,2,4,5,6,7] if it was rotated 7 times. Notice that rotating an array [a[0], a[1], a[2], ..., a[n-1]] 1 time results in the array [a[n-1], a[0], a[1], a[2], ..., a[n-2]]. Given the sorted ro..

    2021.10.27
1 ··· 6 7 8 9 10 11 12 ··· 16
티스토리
© 2018 TISTORY. All rights reserved.

티스토리툴바