1. Calculate the Result of a String Expression
Write a function that takes a string containing a mathematical expression composed of non-negative integers and the '+' and '-' operators, such as '3+2+5' or '0-2-4', and returns the calculated result as an integer. For example, the input '3+2+5' should return 10, and '0-2-4' should return -6.
2. Implement an LRU Cache with Generics
Design and implement an LRU (Least Recently Used) cache that supports the following operations: get and put. The cache should be able to hold a number of key-value pairs with a predefined capacity and should remove the least recently used item when the capacity is exceeded. Additionally, implement generics to allow the cache to handle different data types.
3. Dynamic Programming Problem
The task involves a dynamic programming problem, which seems to be about minimizing latency by dividing a graph into several unconnected groups. Provide a solution approach for this problem.
4. Understanding JSON Web Tokens
Explain the purpose of the two provided code snippets related to JSON Web Tokens.