[BOJ] 13537 수열과 쿼리 1Read more
[BOJ] 10999 구간 합 구하기 2Read more
[LeetCode] Minimum Time to Collect All Apples in a Tree

1443. Minimum Time to Collect All Apples in a Tree

Given an undirected tree consisting of n vertices numbered from 0 to n-1, which has some apples in their vertices. You spend 1 second to walk over one edge of the tree. Return the minimum time in seconds you have to spend to collect all apples in the tree, starting at vertex 0 and coming back to this vertex.

The edges of the undirected tree are given in the array edges, where edges[i] = [ai, bi] means that exists an edge connecting the vertices ai and bi. Additionally, there is a boolean array hasApple, where hasApple[i] = true means that vertex i has an apple; otherwise, it does not have any apple.

Read more
[BOJ] 3012 올바른 괄호 문자열Read more
[BOJ] 11439 이항 계수 5Read more
[BOJ] 11402 이항 계수 4Read more
[LeetCode] Valid Number

65. Valid Number

A valid number can be split up into these components (in order):

  1. A decimal number or an integer.
  2. (Optional) An ‘e’ or ‘E’, followed by an integer.

A decimal number can be split up into these components (in order):

  1. (Optional) A sign character (either ‘+’ or ‘-‘).
  2. One of the following formats:
  1. One or more digits, followed by a dot ‘.’.
  2. One or more digits, followed by a dot ‘.’, followed by one or more digits.
  3. A dot ‘.’, followed by one or more digits.

An integer can be split up into these components (in order):

  1. (Optional) A sign character (either ‘+’ or ‘-‘).
  2. One or more digits.

For example, all the following are valid numbers: [“2”, “0089”, “-0.1”, “+3.14”, “4.”, “-.9”, “2e10”, “-90E3”, “3e+7”, “+6e-1”, “53.5e93”, “-123.456e789”], while the following are not valid numbers: [“abc”, “1a”, “1e”, “e3”, “99e2.5”, “—6”, “-+3”, “95a54e53”].

Given a string s, return true if s is a valid number.

Read more
[BOJ] 5916 농장 관리Read more
[BOJ] 18227 성대나라의 물탱크Read more
[BOJ] 16404 주식회사 승범이네Read more