FastPrepFastPrep
Problem Brief

Dynamic Path Accessor

OA

Hi! Just a heads-up ~ FastPrep currently doesn't support dictionaries as an input type, so submitting code with that will throw errors. But no worries! The problem statement is pretty clear about what’s expected 🍻

Implement a function called get_dict_value that takes two arguments: a dictionary called dict and a string called path. The path string represents the nested keys of the dictionary, separated by dots. The function should return the value at the specified path or None (the Python null value, not a string) if the path does not exist.

Function Description

Complete the function get_dict_value in the editor below.

get_dict_value has the following parameters:

  • obj: a Python dictionary
  • string path: the path to the desired value if it exists

Returns

The value at the specified path, or None (the Python null value, not a string) if the path does not exist

1Example 1

Input
obj = [["car"], [":"], ["wheels", ":", "2", "gears", ":", "5"]], path = "car.gears"
Output
5
Explanation
The function call get_dict_value(obj, "car.gears") should return 5.

Constraints

Limits and guarantees your solution can rely on.

1 ≤ n(number of strings) ≤ 500
public String breakPalindrome(String[][] obj, String path) {
  // write your code here
}
Input

obj

[["car"], [":"], ["wheels", ":", "2", "gears", ":", "5"]]

path

"car.gears"

Output

5

Sign in to submit your solution.