codeparrot/xlcost-text-to-code huggingface dataset:
Find i 'th Index character in a binary string obtained after n iterations | Java Program to find ith character in a binary String . ; Function to store binary Representation ; Function to find ith character ; Function to change decimal to binary ; Assign s1 String in s String ; Driver Code
import java . io . * ; import java . util . Arrays ; class GFG { static String s = " " ; static String ReverseString ( String s ) { char [ ] arr = s . toCharArray ( ) ; for ( int i = 0 ; i < arr . length / 2 ; i ++ ) { char temp = arr [ i ] ; arr [ i ] = arr [ arr . length - i - 1 ] ; arr [ arr . length - i - 1 ] = temp ; } return new String ( arr ) ; } static void binary_conversion ( int m ) { while ( m != 0 ) { int tmp = m % 2 ; s += Integer . toString ( tmp ) ; m = ( int ) ( m / 2 ) ; } s = ReverseString ( s ) ; } static int find_character ( int n , int m , int i ) { binary_conversion ( m ) ; String s1 = " " ; for ( int x = 0 ; x < n ; x ++ ) { for ( int y = 0 ; y < s . length ( ) ; y ++ ) { if ( s . charAt ( y ) == '1' ) s1 += "10" ; else s1 += "01" ; } s = s1 ; s1 = " " ; } return s . charAt ( i ) - '0' ; } public static void main ( String args [ ] ) { int m = 5 , n = 2 , i = 8 ; System . out . print ( find_character ( n , m , i ) ) ; } }
Maximum segment value after putting k breakpoints in a number | Java program to find the maximum segment value after putting k breaks . ; Function to Find Maximum Number ; Maximum segment length ; Find value of first segment of seg_len ; Find value of remaining segments using sliding window ; To find value of current segment , first remove leading digit from previous value ; Then add trailing digit ; Driver code
class GFG { static int findMaxSegment ( String s , int k ) { int seg_len = s . length ( ) - k ; int res = 0 ; for ( int i = 0 ; i < seg_len ; i ++ ) res = res * 10 + ( s . charAt ( i ) - '0' ) ; int seg_len_pow = ( int ) Math . pow ( 10 , seg_len - 1 ) ; int curr_val = res ; for ( int i = 1 ; i <= ( s . length ( ) - seg_len ) ; i ++ ) { curr_val = curr_val - ( s . charAt ( i - 1 ) - '0' ) * seg_len_pow ; curr_val = curr_val * 10 + ( s . charAt ( i + seg_len - 1 ) - '0' ) ; res = Math . max ( res , curr_val ) ; } return res ; } public static void main ( String [ ] args ) { String s = "8754" ; int k = 2 ; System . out . print ( " Maximum ▁ number ▁ = ▁ " + findMaxSegment ( s , k ) ) ; } }
Consecutive sequenced numbers in a string | Java Program to check whether a String contains consecutive sequential numbers or not ; function to check consecutive sequential number ; variable to store starting number ; length of the input String ; find the number till half of the String ; new String containing the starting substring of input String ; converting starting substring into number ; backing up the starting number in start ; while loop until the new_String is smaller than input String ; next number ; concatenate the next number ; check if new String becomes equal to input String ; if String doesn 't contains consecutive numbers ; Driver Code
class GFG { static int isConsecutive ( String str ) { int start ; int length = str . length ( ) ; for ( int i = 0 ; i < length / 2 ; i ++ ) { String new_str = str . substring ( 0 , i + 1 ) ; int num = Integer . parseInt ( new_str ) ; start = num ; while ( new_str . length ( ) < length ) { num ++ ; new_str = new_str + String . valueOf ( num ) ; } if ( new_str . equals ( str ) ) return start ; } return - 1 ; } public static void main ( String [ ] args ) { String str = "99100" ; System . out . println ( " String : ▁ " + str ) ; int start = isConsecutive ( str ) ; if ( start != - 1 ) System . out . println ( "Yes NEW_LINE" + start); else System . out . println ( " No " ) ; String str1 = "121315" ; System . out . println ( " String : " + str1); start = isConsecutive ( str1 ) ; if ( start != - 1 ) System . out . println ( "Yes NEW_LINE" + start); else System . out . println ( " No " ) ; } }
Converting one string to other using append and delete last operations | java Program to convert str1 to str2 in exactly k operations ; Returns true if it is possible to convert str1 to str2 using k operations . ; Case A ( i ) ; finding common length of both string ; Case A ( ii ) - ; Case B ; Driver program
import java . io . * ; class GFG { static boolean isConvertible ( String str1 , String str2 , int k ) { if ( ( str1 . length ( ) + str2 . length ( ) ) < k ) return true ; int commonLength = 0 ; for ( int i = 0 ; i < Math . min ( str1 . length ( ) , str2 . length ( ) ) ; i ++ ) { if ( str1 == str2 ) commonLength ++ ; else break ; } if ( ( k - str1 . length ( ) - str2 . length ( ) + 2 * commonLength ) % 2 == 0 ) return true ; return false ; } public static void main ( String [ ] args ) { String str1 = " geek " ; String str2 = " geek " ; int k = 7 ; if ( isConvertible ( str1 , str2 , k ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; str1 = " geeks " ; str2 = " geek " ; k = 5 ; if ( isConvertible ( str1 , str2 , k ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }
Maximum distinct lowercase alphabets between two uppercase | Java Program to find maximum lowercase alphabets present between two uppercase alphabets ; Function which computes the maximum number of distinct lowercase alphabets between two uppercase alphabets ; Ignoring lowercase characters in the beginning . ; We start from next of first capital letter and traverse through remaining character . ; If character is in uppercase , ; Count all distinct lower case characters ; Update maximum count ; Reset count array ; If character is in lowercase ; Driver code
import java . util . Arrays ; class GFG { static final int MAX_CHAR = 26 ; static int maxLower ( String str ) { int n = str . length ( ) ; int i = 0 ; for ( ; i < n ; i ++ ) { if ( str . charAt ( i ) >= ' A ' && str . charAt ( i ) <= ' Z ' ) { i ++ ; break ; } } int maxCount = 0 ; int count [ ] = new int [ MAX_CHAR ] ; for ( ; i < n ; i ++ ) { if ( str . charAt ( i ) >= ' A ' && str . charAt ( i ) <= ' Z ' ) { int currCount = 0 ; for ( int j = 0 ; j < MAX_CHAR ; j ++ ) { if ( count [ j ] > 0 ) { currCount ++ ; } } maxCount = Math . max ( maxCount , currCount ) ; Arrays . fill ( count , 0 ) ; } if ( str . charAt ( i ) >= ' a ' && str . charAt ( i ) <= ' z ' ) { count [ str . charAt ( i ) - ' a ' ] ++ ; } } return maxCount ; } public static void main ( String [ ] args ) { String str = " zACaAbbaazzC " ; System . out . println ( maxLower ( str ) ) ; } }
Maximum distinct lowercase alphabets between two uppercase | Java Program to find maximum lowercase alphabets present between two uppercase alphabets ; Function which computes the maximum number of distinct lowercase alphabets between two uppercase alphabets ; Ignoring lowercase characters in the beginning . ; We start from next of first capital letter and traverse through remaining character . ; If character is in uppercase , ; Update maximum count if lowercase character before this is more . ; clear the set ; If character is in lowercase ; Driver Code
import java . util . * ; class GFG { static int maxLower ( char [ ] str ) { int n = str . length ; int i = 0 ; for ( ; i < n ; i ++ ) { if ( str [ i ] >= ' A ' && str [ i ] <= ' Z ' ) { i ++ ; break ; } } int maxCount = 0 ; HashSet < Integer > s = new HashSet < Integer > ( ) ; for ( ; i < n ; i ++ ) { if ( str [ i ] >= ' A ' && str [ i ] <= ' Z ' ) { maxCount = Math . max ( maxCount , ( int ) s . size ( ) ) ; s . clear ( ) ; } if ( str [ i ] >= ' a ' && str [ i ] <= ' z ' ) s . add ( ( int ) str [ i ] ) ; } return maxCount ; } public static void main ( String args [ ] ) { String str = " zACaAbbaazzC " ; System . out . println ( maxLower ( str . toCharArray ( ) ) ) ; } }
First uppercase letter in a string ( Iterative and Recursive ) | Java program to find the first uppercase letter using linear search ; Function to find string which has first character of each word . ; Driver program
import java . io . * ; import java . util . * ; class GFG { static char first ( String str ) { for ( int i = 0 ; i < str . length ( ) ; i ++ ) if ( Character . isUpperCase ( str . charAt ( i ) ) ) return str . charAt ( i ) ; return 0 ; } public static void main ( String args [ ] ) { String str = " geeksforGeeKS " ; char res = first ( str ) ; if ( res == 0 ) System . out . println ( " No ▁ uppercase ▁ letter " ) ; else System . out . println ( res ) ; } }
Count maximum | Java implementation for counting maximum length palindromes ; factorial of a number ; function to count maximum length palindromes . ; Count number of occurrence of a charterer in the string ; int k = 0 ; Count of singles int num = 0 ; numerator of result int den = 1 ; denominator of result ; if frequency is even fi = ci / 2 ; if frequency is odd fi = ci - 1 / 2. ; sum of all frequencies ; product of factorial of every frequency ; if all character are unique so there will be no pallindrome , so if num != 0 then only we are finding the factorial ; k are the single elements that can be placed in middle ; Driver code
import java . util . * ; class GFG { static int fact ( int n ) { int ans = 1 ; for ( int i = 1 ; i <= n ; i ++ ) ans = ans * i ; return ( ans ) ; } static int numberOfPossiblePallindrome ( String str , int n ) { Map < Character , Integer > mp = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) mp . put ( str . charAt ( i ) , mp . get ( str . charAt ( i ) ) == null ? 1 : mp . get ( str . charAt ( i ) ) + 1 ) ; int fi ; for ( Map . Entry < Character , Integer > it : mp . entrySet ( ) ) { if ( it . getValue ( ) % 2 == 0 ) fi = it . getValue ( ) / 2 ; else { fi = ( it . getValue ( ) - 1 ) / 2 ; k ++ ; } num = num + fi ; den = den * fact ( fi ) ; } if ( num != 0 ) num = fact ( num ) ; int ans = num / den ; if ( k != 0 ) { ans = ans * k ; } return ( ans ) ; } public static void main ( String [ ] args ) { String str = " ababab " ; int n = str . length ( ) ; System . out . println ( numberOfPossiblePallindrome ( str , n ) ) ; } }
Counting even decimal value substrings in a binary string | Java Program to count all even decimal value substring . ; generate all substring in arr [ 0. . n - 1 ] ; store the count ; Pick starting point ; Pick ending point ; substring between current starting and ending points ; increment power of 2 by one ; Driver code
import java . io . * ; class GFG { static int evenDecimalValue ( String str , int n ) { int result = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i ; j < n ; j ++ ) { int decimalValue = 0 ; int powerOf2 = 1 ; for ( int k = i ; k <= j ; k ++ ) { decimalValue += ( ( str . charAt ( k ) - '0' ) * powerOf2 ) ; powerOf2 *= 2 ; } if ( decimalValue % 2 == 0 ) result ++ ; } } return result ; } public static void main ( String [ ] args ) { String str = "10010" ; int n = 5 ; System . out . println ( evenDecimalValue ( str , n ) ) ; } }
Create a new string by alternately combining the characters of two halves of the string in reverse | Java program for creating a string by alternately combining the characters of two halves in reverse ; Function performing calculations ; Calculating the two halves of string s as first and second The final string p ; It joins the characters to final string in reverse order ; It joins the characters to final string in reverse order ; Driver method ; Calling function
import java . io . * ; class GFG { public static void solve ( String s ) { int l = s . length ( ) ; int x = l / 2 ; int y = l ; String p = " " ; while ( x > 0 && y > l / 2 ) { char ch = s . charAt ( x - 1 ) ; p += ch ; x -- ; ch = s . charAt ( y - 1 ) ; p += ch ; y -- ; } if ( y > l / 2 ) { char ch = s . charAt ( x - 1 ) ; p += ch ; y -- ; } System . out . println ( p ) ; } public static void main ( String args [ ] ) { String s = " sunshine " ; solve ( s ) ; } }
Program for length of a string using recursion | java program to calculate length of a string using recursion ; Function to calculate length ; if we reach at the end of the string ; Driver program to test above function
import java . util . * ; public class GFG { private static int recLen ( String str ) { if ( str . equals ( " " ) ) return 0 ; else return recLen ( str . substring ( 1 ) ) + 1 ; } public static void main ( String [ ] args ) { String str = " GeeksforGeeks " ; System . out . println ( recLen ( str ) ) ; } }
Count consonants in a string ( Iterative and recursive methods ) | Iterative Java program to count total number of consonants ; Function to check for consonant ; To handle lower case ; To check is character is Consonant ; Driver code
import java . io . * ; class GFG { static boolean isConsonant ( char ch ) { ch = Character . toUpperCase ( ch ) ; return ! ( ch == ' A ' ch == ' E ' ch == ' I ' ch == ' O ' ch == ' U ' ) && ch >= 65 && ch <= 90 ; } static int totalConsonants ( String str ) { int count = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) if ( isConsonant ( str . charAt ( i ) ) ) ++ count ; return count ; } public static void main ( String args [ ] ) { String str = " abc ▁ de " ; System . out . println ( totalConsonants ( str ) ) ; } }
Count consonants in a string ( Iterative and recursive methods ) | Recursive Java program to count total number of consonants ; Function to check for consonant ; To handle lower case ; to count total number of consonants from 0 to n - 1 ; Driver code
import java . util . * ; import java . lang . * ; class GFG { static boolean isConsonant ( char ch ) { ch = Character . toUpperCase ( ch ) ; return ( ch == ' A ' ch == ' E ' ch == ' I ' ch == ' O ' ch == ' U ' ) == false && ch >= 65 && ch <= 90 ; } static int totalConsonants ( String str , int n ) { if ( n == 1 ) { if ( isConsonant ( str . charAt ( 0 ) ) ) return 1 ; else return 0 ; } if ( isConsonant ( str . charAt ( n - 1 ) ) ) return totalConsonants ( str , n - 1 ) + 1 ; else return totalConsonants ( str , n - 1 ) ; } public static void main ( String args [ ] ) { String str = " abc ▁ de " ; System . out . println ( totalConsonants ( str , str . length ( ) ) ) ; } }
Check if actual binary representation of a number is palindrome | Java code to check whether binary representation of a number is palindrome or not ; function to reverse bits of a number ; traversing bits of ' n ' from the right ; bitwise left shift ' rev ' by 1 ; if current bit is '1' ; bitwise right shift ' n ' by 1 ; required number ; function to check a number is palindrome or not ; get the number by reversing bits in the binary representation of ' n ' ; Driver function
import java . util . * ; import java . lang . * ; public class GfG { public static long reverseBits ( long n ) { long rev = 0 ; while ( n > 0 ) { rev <<= 1 ; if ( ( n & 1 ) == 1 ) rev ^= 1 ; n >>= 1 ; } return rev ; } public static boolean isPalindrome ( long n ) { long rev = reverseBits ( n ) ; return ( n == rev ) ; } public static void main ( String argc [ ] ) { long n = 9 ; if ( isPalindrome ( n ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }
Reduce Hamming distance by swapping two characters | Java code to decrease hamming distance using swap . ; Function to return the swapped indexes to get minimum hamming distance . ; Find the initial hamming distance ; Case - I : To decrease distance by two ; ASCII values of present character . ; If two same letters appear in different positions print their indexes ; Store the index of letters which is in wrong position ; Case : II ; If misplaced letter is found , print its original index and its new index ; Store the index of letters in wrong position ; Case - III ; Driver code
import java . util . Arrays ; class GFG { static final int MAX = 26 ; static void Swap ( String s , String t , int n ) { int dp [ ] [ ] = new int [ MAX ] [ MAX ] ; for ( int i = 0 ; i < MAX ; i ++ ) { for ( int j = 0 ; j < MAX ; j ++ ) { dp [ i ] [ j ] = - 1 ; } } int tot = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( s . charAt ( i ) != t . charAt ( i ) ) tot ++ ; for ( int i = 0 ; i < n ; i ++ ) { int a = s . charAt ( i ) - ' a ' ; int b = t . charAt ( i ) - ' a ' ; if ( a == b ) continue ; if ( dp [ a ] [ b ] != - 1 ) { System . out . println ( i + 1 + " ▁ " + ( dp [ a ] [ b ] + 1 ) ) ; return ; } dp [ b ] [ a ] = i ; } int A [ ] = new int [ MAX ] , B [ ] = new int [ MAX ] ; Arrays . fill ( A , - 1 ) ; Arrays . fill ( B , - 1 ) ; for ( int i = 0 ; i < n ; i ++ ) { int a = s . charAt ( i ) - ' a ' ; int b = t . charAt ( i ) - ' a ' ; if ( a == b ) continue ; if ( A [ b ] != - 1 ) { System . out . println ( i + 1 + " ▁ " + ( A [ b ] + 1 ) ) ; return ; } if ( B [ a ] != - 1 ) { System . out . println ( i + 1 + " ▁ " + ( B [ a ] + 1 ) ) ; return ; } A [ a ] = i ; B [ b ] = i ; } System . out . println ( - 1 ) ; } public static void main ( String [ ] args ) { String S = " permanent " ; String T = " pergament " ; int n = S . length ( ) ; if ( S == " " T == " " ) System . out . println ( " Required ▁ string ▁ is ▁ empty . " ) ; else Swap ( S , T , n ) ; } }
Convert string X to an anagram of string Y with minimum replacements | Java program to convert string X to string Y which minimum number of changes . ; Function that converts string X into lexicographically smallest anagram of string Y with minimal changes ; Counting frequency of characters in each string . ; We maintain two more counter arrays ctrx [ ] and ctry [ ] Ctrx [ ] maintains the count of extra elements present in string X than string Y Ctry [ ] maintains the count of characters missing from string X which should be present in string Y . ; This means that we cannot edit the current character as it 's frequency  in string X is equal to or less  than the frequency in string Y.  Thus, we go to the next position ; Here , we try to find that character , which has more frequency in string Y and less in string X . We try to find this character in lexicographical order so that we get lexicographically smaller string ; This portion deals with the lexicographical property . Now , we put a character in string X when either this character has smaller value than the character present there right now or if this is the last position for it to exchange , else we fix the character already present here in this position . ; Driver code
class GFG { static final int MAX = 26 ; static void printAnagramAndChanges ( char [ ] X , char [ ] Y ) { int countx [ ] = new int [ MAX ] , county [ ] = new int [ MAX ] , ctrx [ ] = new int [ MAX ] , ctry [ ] = new int [ MAX ] ; int change = 0 ; int l = X . length ; for ( int i = 0 ; i < l ; i ++ ) { countx [ X [ i ] - ' A ' ] ++ ; county [ Y [ i ] - ' A ' ] ++ ; } for ( int i = 0 ; i < MAX ; i ++ ) { if ( countx [ i ] > county [ i ] ) { ctrx [ i ] += ( countx [ i ] - county [ i ] ) ; } else if ( countx [ i ] < county [ i ] ) { ctry [ i ] += ( county [ i ] - countx [ i ] ) ; } change += Math . abs ( county [ i ] - countx [ i ] ) ; } for ( int i = 0 ; i < l ; i ++ ) { if ( ctrx [ X [ i ] - ' A ' ] == 0 ) { continue ; } int j ; for ( j = 0 ; j < MAX ; j ++ ) { if ( ( ctry [ j ] ) > 0 ) { break ; } } if ( countx [ X [ i ] - ' A ' ] == ctrx [ X [ i ] - ' A ' ] X [ i ] - ' A ' > j ) { countx [ X [ i ] - ' A ' ] -- ; ctrx [ X [ i ] - ' A ' ] -- ; ctry [ j ] -- ; X [ i ] = ( char ) ( ' A ' + j ) ; } else { countx [ X [ i ] - ' A ' ] -- ; } } System . out . println ( " Anagram ▁ : ▁ " + String . valueOf ( X ) ) ; System . out . println ( " Number ▁ of ▁ changes ▁ made ▁ : ▁ " + change / 2 ) ; } public static void main ( String [ ] args ) { String x = " CDBABC " , y = " ADCABD " ; printAnagramAndChanges ( x . toCharArray ( ) , y . toCharArray ( ) ) ; } }
Count number of equal pairs in a string | Java program to count the number of pairs ; Function to count the number of equal pairs ; Hash table ; Traverse the string and count occurrence ; Stores the answer ; Traverse and check the occurrence of every character ; Driver Code
import java . io . * ; class GFG { static int MAX = 256 ; static int countPairs ( String s ) { int cnt [ ] = new int [ MAX ] ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) cnt [ s . charAt ( i ) ] ++ ; int ans = 0 ; for ( int i = 0 ; i < MAX ; i ++ ) ans += cnt [ i ] * cnt [ i ] ; return ans ; } public static void main ( String [ ] args ) { String s = " geeksforgeeks " ; System . out . println ( countPairs ( s ) ) ; } }
Find a string in lexicographic order which is in between given two strings | Java program to find the string in lexicographic order which is in between given two strings ; Function to find the lexicographically next string ; Iterate from last character ; If not ' z ' , increase by one ; if ' z ' , change it to ' a ' ; Driver Code ; If not equal , print the resultant string
class GFG { static String lexNext ( String str , int n ) { char [ ] s = str . toCharArray ( ) ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( s [ i ] != ' z ' ) { s [ i ] ++ ; return String . valueOf ( s ) ; } s [ i ] = ' a ' ; } return null ; } static public void main ( String [ ] args ) { String S = " abcdeg " , T = " abcfgh " ; int n = S . length ( ) ; String res = lexNext ( S , n ) ; if ( res != T ) { System . out . println ( res ) ; } else { System . out . println ( " - 1" ) ; } } }
Find the arrangement of queue at given time | Java program to find the arrangement of queue at time = t ; prints the arrangement at time = t ; Checking the entire queue for every moment from time = 1 to time = t . ; If current index contains ' B ' and next index contains ' G ' then swap . ; Driver function
import java . io . * ; class Geek { static void solve ( int n , int t , char s [ ] ) { for ( int i = 0 ; i < t ; i ++ ) for ( int j = 0 ; j < n - 1 ; j ++ ) if ( s [ j ] == ' B ' && s [ j + 1 ] == ' G ' ) { char temp = s [ j ] ; s [ j ] = s [ j + 1 ] ; s [ j + 1 ] = temp ; j ++ ; } System . out . print ( s ) ; } public static void main ( String args [ ] ) { int n = 6 , t = 2 ; String s = " BBGBBG " ; char str [ ] = s . toCharArray ( ) ; solve ( n , t , str ) ; } }
Add two numbers represented by two arrays | Java program to sum two numbers represented two arrays . ; Return sum of two number represented by the arrays . Size of a [ ] is greater than b [ ] . It is made sure be the wrapper function ; array to store sum . ; Until we reach beginning of array . we are comparing only for second array because we have already compare the size of array in wrapper function . ; find sum of corresponding element of both array . ; Finding carry for next sum . ; If second array size is less the first array size . ; Add carry to first array elements . ; If there is carry on adding 0 index elements append 1 to total sum . ; Converting array into number . ; Wrapper Function ; Making first array which have greater number of element ; Driver program to test above function
import java . io . * ; class GFG { static int calSumUtil ( int a [ ] , int b [ ] , int n , int m ) { int [ ] sum = new int [ n ] ; int i = n - 1 , j = m - 1 , k = n - 1 ; int carry = 0 , s = 0 ; while ( j >= 0 ) { s = a [ i ] + b [ j ] + carry ; sum [ k ] = ( s % 10 ) ; carry = s / 10 ; k -- ; i -- ; j -- ; } while ( i >= 0 ) { s = a [ i ] + carry ; sum [ k ] = ( s % 10 ) ; carry = s / 10 ; i -- ; k -- ; } int ans = 0 ; if ( carry == 1 ) ans = 10 ; for ( i = 0 ; i <= n - 1 ; i ++ ) { ans += sum [ i ] ; ans *= 10 ; } return ans / 10 ; } static int calSum ( int a [ ] , int b [ ] , int n , int m ) { if ( n >= m ) return calSumUtil ( a , b , n , m ) ; else return calSumUtil ( b , a , m , n ) ; } public static void main ( String [ ] args ) { int a [ ] = { 9 , 3 , 9 } ; int b [ ] = { 6 , 1 } ; int n = a . length ; int m = b . length ; System . out . println ( calSum ( a , b , n , m ) ) ; } }