My Software Engineering

My Software Engineering

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

My Software Engineering

컨텐츠 검색

태그

최근글

댓글

공지사항

아카이브

Leetcode(93)

  • 235. Lowest Common Ancestor of a Binary Search Tree

    Description: Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes p and q as the lowest node in T that has both p and q as descendants (where we allow a node to be a descendant of itself).” # Definition for a binary tree node. # class TreeNod..

    2021.11.17
  • 62. Unique Paths

    Description: A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below). How many possible unique paths are there? ''' [1] dp) idea:: paths[i][j]=path[i-1][j]+path[i][j-1] code:: def unique..

    2021.11.17
  • 230. Kth Smallest Element in a BST

    Description: Given the root of a binary search tree, and an integer k, return the kth smallest value (1-indexed) of all the values of the nodes in the 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] recursive) idea:: compare the number of nodes of left sub-tree (denot..

    2021.11.16
  • 98. Validate Binary Search Tree

    Description: Given the root of a binary tree, determine if it is a valid binary search tree (BST). A valid BST is defined as follows: The left subtree of a node contains only nodes with keys less than the node's key. The right subtree of a node contains only nodes with keys greater than the node's key. Both the left and right subtrees must also be binary search trees. # Definition for a binary t..

    2021.11.16
  • 297. Serialize and Deserialize Binary Tree

    Description: Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection link to be reconstructed later in the same or another computer environment. Design an algorithm to serialize and deserialize a binary tree. There is no restriction on how your serialization/deser..

    2021.11.15
  • 124. Binary Tree Maximum Path Sum

    Description: A path in a binary tree is a sequence of nodes where each pair of adjacent nodes in the sequence has an edge connecting them. A node can only appear in the sequence at most once. Note that the path does not need to pass through the root. The path sum of a path is the sum of the node's values in the path. Given the root of a binary tree, return the maximum path sum of any non-empty p..

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

티스토리툴바