반응형

(Original)

Good morning! Here's your coding interview problem for today.

This problem was asked by Google.

Given the root to a binary tree, implement serialize(root), which serializes the tree into a string, and deserialize(s), which deserializes the string back into the tree.

For example, given the following Node class

class Node:
    def __init__(self, val, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right

The following test should pass:

node = Node('root', Node('left', Node('left.left')), Node('right'))
assert deserialize(serialize(node)).left.left.val == 'left.left'

 


(Google번역)

좋은 아침! 오늘의 코딩 인터뷰 문제는 다음과 같습니다.

이 문제는 Google에서 요청했습니다.

이진 트리의 루트가 주어지면 트리를 문자열로 직렬화하는 serialize(root)와 문자열을 다시 트리로 역직렬화하는 deserialize(s)를 구현합니다.

예를 들어 다음 노드 클래스가 주어진 경우

class Node:
    def __init__(self, val, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right

다음 테스트를 통과해야 합니다.

 

node = Node('root', Node('left', Node('left.left')), Node('right'))
assert deserialize(serialize(node)).left.left.val == 'left.left'

 


시간내서 하나씩 고민하고 풀어보기.

(메일에 쌓아둘순 없으니..)

매일 문제을 받고 싶다면 아래 링크에서 구독해보세요.

(단, 문제 풀이는 프리미엄 구독자만 받을 수 있음)

https://www.dailycodingproblem.com/

 

Daily Coding Problem

There's a staircase with N steps, and you can climb 1 or 2 steps at a time. Given N, write a function that returns the number of unique ways you can climb the staircase. The order of the steps matters. For example, if N is 4, then there are 5 unique ways:

www.dailycodingproblem.com

 

'2023' 카테고리의 다른 글

Dart_1_nomadcoders  (0) 2023.07.24
sql,nosql,앱개발,정처기,,,230616  (0) 2023.06.18
2023.01.14. Daily Coding Problem: Problem #1 [Easy]  (0) 2023.01.16
2023.01.13.vue build  (0) 2023.01.13
2023.01.12.  (0) 2023.01.12

+ Recent posts