There are N gas stations along a circular route, where the amount of gas at station i is gas. You have a motorcycle with an unlimited gas tank and it costs cost of gas to travel from station i to its next station (i+1). You begin …

Example: Input: "aab" Output: , ] The solution for this problem can be done with the help of DFS. The logic is to loop through the string one by one. Once we find a palindromic string for the string str(0, i) we store the current string …

Example 1: Input: Output: 1 We can solve this by 2 methods: unordered_map XOR operation. We shall discuss both of the solutions in this tutorial. Solution using unordered_map. Use unordered_map, increment the “second” in unordered_map when ever you get an element. At the end, iterate throughout …