Write a function that takes in a Binary Tree and returns a list of its branch sums ordered from leftmost branch sum to rightmost branch sum.A branch sum is the sum of all values in a Binary Tree branch. A Binary Tree branch is a path of nodes in a tree that starts at the root node and ends at any leaf node.Each BinaryTree node has an integer value, a left child node, and a right child node. Children nodes can either be BinaryTree nodes themselves or None / null.Sample Inputtree = 1 / \ 2 3 / \ / \ 4 5 6 7 / \ / 8 9 10Sample Output[15, 16, 18, 10, 11]// 15 == 1 + 2 + 4 + 8// 16 == 1 + 2 + 4 + 9// 18 == 1 + 2 + 5 + 10// 10 == 1 + 3 + 6// 11 == 1 + 3 + 7
Write a function that takes in a string of lowercase English-alphabet letters and returns the index of the string's first non-repeating character. The first non-repeating character is the first character in a string that occurs only once. If the input string doesn't have any non-repeating characters, your function should return -1. Sample Input string = "abcdcaf" Sample Output 1 // The first non-repeating character is "b" and is found at index 1.
You're given a string of available characters and a string representing a document that you need to generate. Write a function that determines if you can generate the document using the available characters. If you can generate the document, your function should return true; otherwise, it should return false. You're only able to generate the document if the frequency of unique characters in the characters string is greater than or equal to the frequency of unique characters in the document string. For example, if you're given characters = "abcabc" and document = "aabbccc" you cannot generate the document because you're missing one c. The document that you need to create may contain any characters, including special characters, capital letters, numbers, and spaces. Note: you can always generate the empty string (""). Sample Input characters = "aheaollabbhb" document = "hello" Sample Output true