Question Design a student grade management system consisting of two classes: Student and Result. Student Class Implement a Student class...
Input: String Output: Printed output
codingMediumtree#1
1. Binary Tree Depth Calculation — Calculate the maximum depth of a binary tree
Background: PayPal employs complex data structures to manage transaction workflows and user account hierarchies. Understanding the depth of binary trees can help optimize search operations in these systems. Problem statement: Given a binary tree, determine its maximum depth. The function should return the number of nodes along the longest path from the root node down to the farthest leaf node. A leaf is a node with no children. Function/class signature:
def max_depth(root: Optional[TreeNode]) -> int:
Example 1:
Input: root = [3,9,20,null,null,15,7]
Output: 3
Explanation: The maximum depth is 3 because the longest path is 3 -> 20 -> 15.
Example 2:
Input: root = [1,null,2]
Output: 2
Explanation: The maximum depth is 2 because the longest path is 1 -> 2.
Constraints:
Node count in the tree can range from 0 to 1000.
Each node's value is at most 1000.
root can be None for an empty tree.
codingHardgraph#2
2. Graph Traversal — Find the shortest path for a payment transaction
Background: PayPal handles a vast number of transactions daily, and optimizing the transaction routing is crucial for efficiency and speed. This problem relates to optimizing how payment transactions traverse through multiple gateways. Problem statement: Given a directed graph where nodes represent payment gateways and edges represent the transaction routes with associated costs, you need to find the shortest path from a source gateway to a destination gateway. Return the total cost of the shortest path and the path itself as a list of gateways. Function/class signature:
Explanation: The optimal route is direct via B with a total cost of 5.
Constraints:
1 ≤ number of links ≤ 1000
Cost of each route (edge weight) is positive and ≤ 1000
All nodes (gateways) are unique strings.
codingHardgraph#3
3. MAXIMUM FLOW — Calculate the maximum flow in a payment network
Background: In financial systems like PayPal, it is essential to optimize payment routes to ensure efficient transaction handling. The maximum flow algorithm helps in managing the flow of transactions through various payment channels. Problem statement: You are given a directed graph where nodes represent payment channels, and edges represent possible transaction flows with capacity limits. Your task is to implement a function that computes the maximum flow from a source node to a sink node. You need to return the total maximum flow achievable from the source to the sink. Function/class signature:
Explanation: The maximum flow for this network is 20.
Constraints:
2 <= graph.length <= 100
0 <= graph[i][j] <= 1000
source and sink are valid indices in graph, with source != sink.
codingMediumgraph#4
4. Graph — Find the Shortest Payment Path
Background: In financial transactions, finding the shortest path for payments between two linked financial institutions can optimize transaction processing. This relates to PayPal’s payment system, aiming to minimize transaction fees and times.Problem statement: Given a directed acyclic graph where nodes represent financial institutions and edges represent transaction fees between them, write a function to find the minimum transaction fee necessary to transfer money from a starting institution to a target institution. The output should indicate both the minimum fee and the path taken.Function/class signature:
Example 1: Input: start = "A", target = "C", edges = [("A", "B", 1), ("B", "C", 2), ("A", "C", 5)] Output: (3, ["A", "B", "C"]) Explanation: The minimum fee from A to C is through B with a total fee of 3 (1 + 2).Example 2: Input: start = "A", target = "D", edges = [("A", "B", 4), ("B", "C", 2), ("C", "D", 1), ("A", "D", 10)] Output: (7, ["A", "B", "C", "D"])Constraints:
The graph will have at most 100 nodes.
Each edge's transaction fee will be a positive integer not exceeding 100.
There may be multiple edges between two nodes but only one directional path exists in the graph.
Node names will consist of uppercase letters only.
codingHardgraph#5
5. CODING — Longest Path in a Directed Acyclic Graph
Background: PayPal relies on robust data processing workflows that often involve directed acyclic graphs (DAGs) for transaction processing and workflow automation. Optimizing these workflows is crucial for efficiency and accuracy. Problem statement: Given a directed acyclic graph represented as an adjacency list, write a function to determine the length of the longest path from any starting node to any ending node. Implement it with a focus on efficiency due to large transaction sets. Function/class signature: