You are using an outdated browser. For a faster, safer browsing experience, upgrade for free today.
R
51 lượt xem

Coding Interview: Problem #3 [Medium]

Learning Programming language With The ÂN

Coding Interview: Problem #3 [Medium]

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'
					
				

If you can not solve the above problem, you can contact us via email info@bmavietnam.com. We are ready to support you.

Bài viết khác
Lợi ích của Phòng IT thuê ngoài?
Lợi ích của Phòng IT thuê ngoài?

Phòng IT thuê ngoài, hay còn gọi là dịch vụ IT dựa trên mô hình outsource, mang lại nhiều lợi ích cho các doanh nghiệp, nhất là đối với những công ty không chuyên về công nghệ thông tin. ...