My Software Engineering

My Software Engineering

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

My Software Engineering

컨텐츠 검색

태그

최근글

댓글

공지사항

아카이브

Leetcode(93)

  • 300. Longest Increasing Subsequence

    Description: Given an integer array nums, return the length of the longest strictly increasing subsequence. A subsequence is a sequence that can be derived from an array by deleting some or no elements without changing the order of the remaining elements. For example, [3,6,2,7] is a subsequence of the array [0,3,1,6,2,2,7]. ''' [1] brute force) -idea:: when, cur_num==-float(inf), from idx==0 to ..

    2021.11.26
  • 435. Non-overlapping Intervals

    Description: Given an array of intervals intervals where intervals[i] = [starti, endi], return the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping. ''' [1] sort and greedy) -idea:: sort intervals(key is interval[0]) then, keep end point(interval[0]) while comparing next interval with end, It is advantageous to remove longer interval (greedy approa..

    2021.11.21
  • 57. Insert Interval

    Description: You are given an array of non-overlapping intervals intervals where intervals[i] = [starti, endi] represent the start and the end of the ith interval and intervals is sorted in ascending order by starti. You are also given an interval newInterval = [start, end] that represents the start and end of another interval. Insert newInterval into intervals such that intervals is still sorte..

    2021.11.21
  • 106. Construct Binary Tree from Inorder and Postorder Traversal

    Description: Given two integer arrays inorder and postorder where inorder is the inorder traversal of a binary tree and postorder is the postorder traversal of the same tree, construct and return the binary tree. # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right ''' [1] divide and se..

    2021.11.21
  • 540. Single Element in a Sorted Array

    Description: You are given a sorted array consisting of only integers where every element appears exactly twice, except for one element which appears exactly once. Return the single element that appears only once. Your solution must run in O(log n) time and O(1) space. ''' [1] binary search) idea:: set left and right. compare mid with both mid-1 and mid+1 code:: def singleNonDuplicate(self, nums..

    2021.11.20
  • 208. Implement Trie (Prefix Tree)

    Description: A trie (pronounced as "try") or prefix tree is a tree data structure used to efficiently store and retrieve keys in a dataset of strings. There are various applications of this data structure, such as autocomplete and spellchecker. Implement the Trie class: Trie() Initializes the trie object. void insert(String word) Inserts the string word into the trie. boolean search(String word)..

    2021.11.17
1 2 3 4 ··· 16
티스토리
© 2018 TISTORY. All rights reserved.

티스토리툴바