Skip to content

Nested dictionary and python object print with their depth, and find LCA in a binary tree solutions with unit tests.

License

Notifications You must be signed in to change notification settings

yasminfarza/python-code-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Code Test

Here are functional solutions for some interesting problems like nested dictionary and python object print with their depth, and find LCA in a binary tree solutions.

Question 1: Write the following function’s body. A nested dictionary is passed as parameter. Need to print all keys with their depth.

This problem-solution appears on /core/dictionary_depth.py and the unit test appears on /tests/test_dict_depth.py file.

Question 2: Write a new function with same functionality from Question 1, but it should be able to handle a Python object in addition to a dictionary from Question 1.

This problem-solution appears on /core/object_depth.py and the unit test appears on /tests/test_obj_depth.py file.

Question 3: Write following functions body. 2 Nodes are passed as parameter. Need to find Least Common Ancestor and print its value.

This problem-solution appears on /core/least_common_ancestor.py and the unit test appears on /tests/test_least_common_ancestor.py file.

And the runtime and memory requirements for this solution is:

  • The time complexity is O(n).
  • The space complexity is constant.

TestCase

To test those solutions, run the command line in the terminal:

$ python -m unittest

About

Nested dictionary and python object print with their depth, and find LCA in a binary tree solutions with unit tests.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages