大家好 我遇到这两道题目。我感觉难,做不来,求大家帮助讲解思路! 如果肯把代码也写出来更谢谢。 3. determine if strings are close
Write a function to determine if two strings are close. For two strings to be considered close, they must be same after doing the either or both of following steps for any number of times: 1) swap any two characters within one string 2) change all occurrences of one character in one string into another character that exists in the same string e.g. "aaaabb" can be converted into "bbbbaa"
4. process queries
Given an integer array (int[] a) and a 2D array(int[][] queries). The 2D array represents a set of queries. You need to process the queries to find the number of occurrence of a specific number in array a between index i and j(inclusive). Each query is formatted in the following way: Each query has size 3(query.length=3, 0<=i<queries.length) The first element is the lower index i. The second element is the higher index j and the third element is the number you are searching for. Return the sum of numbers of occurrences you get from processing all the queries. (Brute force solution will not be efficient enough to pass all test cases).