codeparrot/xlcost-text-to-code huggingface dataset:
Count of distinct substrings of a string using Suffix Trie | A Java program to find the count of distinct substring of a string using trie data structure ; A Suffix Trie ( A Trie of all suffixes ) Node ; SuffixTrieNode ( ) Constructor ; Initialize all child pointers as NULL ; A recursive function to insert a suffix of the s in subtree rooted with this node ; If string has more characters ; Find the first character and convert it into 0 - 25 range . ; If there is no edge for this character , add a new edge ; Recur for next suffix ; A Trie of all suffixes ; Constructor ( Builds a trie of suffies of the given text ) ; Consider all suffixes of given string and insert them into the Suffix Trie using recursive function insertSuffix ( ) in SuffixTrieNode class ; A recursive function to count nodes in trie ; If all characters of pattern have been processed , ; if children is not NULL then find count of all nodes in this subtrie ; return count of nodes of subtrie and plus 1 because of node 's own count ; method to count total nodes in suffix trie ; Returns count of distinct substrings of str ; Construct a Trie of all suffixes ; Return count of nodes in Trie of Suffixes ; Driver program to test above function
public class Suffix { static class SuffixTrieNode { static final int MAX_CHAR = 26 ; SuffixTrieNode [ ] children = new SuffixTrieNode [ MAX_CHAR ] ; { for ( int i = 0 ; i < MAX_CHAR ; i ++ ) children [ i ] = null ; } void insertSuffix ( String s ) { if ( s . length ( ) > 0 ) { char cIndex = ( char ) ( s . charAt ( 0 ) - ' a ' ) ; if ( children [ cIndex ] == null ) children [ cIndex ] = new SuffixTrieNode ( ) ; children [ cIndex ] . insertSuffix ( s . substring ( 1 ) ) ; } } } static class Suffix_trie { static final int MAX_CHAR = 26 ; SuffixTrieNode root ; Suffix_trie ( String s ) { root = new SuffixTrieNode ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) root . insertSuffix ( s . substring ( i ) ) ; } int _countNodesInTrie ( SuffixTrieNode node ) { if ( node == null ) return 0 ; int count = 0 ; for ( int i = 0 ; i < MAX_CHAR ; i ++ ) { if ( node . children [ i ] != null ) count += _countNodesInTrie ( node . children [ i ] ) ; } return ( 1 + count ) ; } int countNodesInTrie ( ) { return _countNodesInTrie ( root ) ; } } static int countDistinctSubstring ( String str ) { Suffix_trie sTrie = new Suffix_trie ( str ) ; return sTrie . countNodesInTrie ( ) ; } public static void main ( String args [ ] ) { String str = " ababa " ; System . out . println ( " Count ▁ of ▁ distinct ▁ substrings ▁ is ▁ " + countDistinctSubstring ( str ) ) ; } }
XOR Cipher | Java program to implement XOR - Encryption ; The same function is used to encrypt and decrypt ; Define XOR key Any character value will work ; Define String to store encrypted / decrypted String ; calculate length of input string ; perform XOR operation of key with every character in string ; Driver code ; Encrypt the string ; Decrypt the string
class XOREncryption { static String encryptDecrypt ( String inputString ) { char xorKey = ' P ' ; String outputString = " " ; int len = inputString . length ( ) ; for ( int i = 0 ; i < len ; i ++ ) { outputString = outputString + Character . toString ( ( char ) ( inputString . charAt ( i ) ^ xorKey ) ) ; } System . out . println ( outputString ) ; return outputString ; } public static void main ( String [ ] args ) { String sampleString = " GeeksforGeeks " ; System . out . println ( " Encrypted ▁ String " ) ; String encryptedString = encryptDecrypt ( sampleString ) ; System . out . println ( " Decrypted ▁ String " ) ; encryptDecrypt ( encryptedString ) ; } }
Compare two Version numbers | Java program to compare two version number ; Method to compare two versions . Returns 1 if v2 is smaller , - 1 if v1 is smaller , 0 if equal ; vnum stores each numeric part of version ; loop until both String are processed ; Storing numeric part of version 1 in vnum1 ; storing numeric part of version 2 in vnum2 ; if equal , reset variables and go for next numeric part ; Driver method to check above comparison function
import java . util . * ; class GFG { static int versionCompare ( String v1 , String v2 ) { int vnum1 = 0 , vnum2 = 0 ; for ( int i = 0 , j = 0 ; ( i < v1 . length ( ) || j < v2 . length ( ) ) ; ) { while ( i < v1 . length ( ) && v1 . charAt ( i ) != ' . ' ) { vnum1 = vnum1 * 10 + ( v1 . charAt ( i ) - '0' ) ; i ++ ; } while ( j < v2 . length ( ) && v2 . charAt ( j ) != ' . ' ) { vnum2 = vnum2 * 10 + ( v2 . charAt ( j ) - '0' ) ; j ++ ; } if ( vnum1 > vnum2 ) return 1 ; if ( vnum2 > vnum1 ) return - 1 ; vnum1 = vnum2 = 0 ; i ++ ; j ++ ; } return 0 ; } public static void main ( String [ ] args ) { String version1 = "1.0.3" ; String version2 = "1.0.7" ; if ( versionCompare ( version1 , version2 ) < 0 ) System . out . println ( version1 + " ▁ is ▁ smaller " ) ; else if ( versionCompare ( version1 , version2 ) > 0 ) System . out . println ( version2 + " ▁ is ▁ smaller " ) ; else System . out . println ( " Both ▁ version ▁ are ▁ equal " ) ; } }
Repeated subsequence of length 2 or more | Java program to check if any repeated subsequence exists in the string ; A function to check if a string str is palindrome ; l and h are leftmost and rightmost corners of str Keep comparing characters while they are same ; The main function that checks if repeated subsequence exists in the string ; Find length of input string ; Create an array to store all characters and their frequencies in str [ ] ; Traverse the input string and store frequencies of all characters in freq [ ] array . ; If the character count is more than 2 we found a repetition ; In - place remove non - repeating characters from the string ; check if the resultant string is palindrome ; special case - if length is odd return true if the middle character is same as previous one ; It is checked so that StringIndexOutOfBounds can be avoided ; return false if string is a palindrome ; return true if string is not a palindrome ; Driver Code
class GFG { static int MAX_CHAR = 256 ; public static boolean isPalindrome ( String str , int l , int h ) { while ( h > l ) if ( str . charAt ( l ++ ) != str . charAt ( h -- ) ) return false ; return true ; } public static boolean check ( String str ) { int n = str . length ( ) ; int [ ] freq = new int [ MAX_CHAR ] ; for ( int i = 0 ; i < n ; i ++ ) { freq [ str . charAt ( i ) ] ++ ; if ( freq [ str . charAt ( i ) ] > 2 ) return true ; } int k = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( freq [ str . charAt ( i ) ] > 1 ) str . replace ( str . charAt ( k ++ ) , str . charAt ( i ) ) ; str . replace ( str . charAt ( k ) , ' \0' ) ; if ( isPalindrome ( str , 0 , k - 1 ) ) { if ( ( k & 1 ) == 1 ) { if ( k / 2 >= 1 ) return ( str . charAt ( k / 2 ) == str . charAt ( k / 2 - 1 ) ) ; } return false ; } return true ; } public static void main ( String [ ] args ) { String str = " ABCABD " ; if ( check ( str ) ) System . out . println ( " Repeated ▁ Subsequence ▁ Exists " ) ; else System . out . println ( " Repeated ▁ Subsequence " + " ▁ Doesn ' t ▁ Exists " ) ; } }
How to find Lexicographically previous permutation ? | Java program to print all permutations with duplicates allowed using prev_permutation ( ) ; Function to compute the previous permutation ; Find index of the last element of the string ; Find largest index i such that str [ i - 1 ] > str [ i ] ; if string is sorted in ascending order we 're  at the last permutation ; Note - str [ i . . n ] is sorted in ascending order Find rightmost element 's index  that is less than str[i - 1] ; Swap character at i - 1 with j ; Reverse the substring [ i . . n ] ; Utility function to swap ; Driver code
class GFG { static boolean prevPermutation ( char [ ] str ) { int n = str . length - 1 ; int i = n ; while ( i > 0 && str [ i - 1 ] <= str [ i ] ) { i -- ; } if ( i <= 0 ) { return false ; } int j = i - 1 ; while ( j + 1 <= n && str [ j + 1 ] <= str [ i - 1 ] ) { j ++ ; } swap ( str , i - 1 , j ) ; StringBuilder sb = new StringBuilder ( String . valueOf ( str ) ) ; sb . reverse ( ) ; str = sb . toString ( ) . toCharArray ( ) ; return true ; } static String swap ( char [ ] ch , int i , int j ) { char temp = ch [ i ] ; ch [ i ] = ch [ j ] ; ch [ j ] = temp ; return String . valueOf ( ch ) ; } public static void main ( String [ ] args ) { char [ ] str = "4321" . toCharArray ( ) ; if ( prevPermutation ( str ) ) { System . out . println ( " Previous ▁ permutation ▁ is ▁ " + String . valueOf ( str ) ) ; } else { System . out . println ( " Previous ▁ permutation " + " doesn ' t ▁ exist " ) ; } } }
Longest Path with Same Values in a Binary Tree | Java program to find the length of longest path with same values in a binary tree . ; A binary tree node has data , pointer to left child and a pointer to right child ; Function to print the longest path of same values ; Recursive calls to check for subtrees ; Variables to store maximum lengths in two directions ; If curr node and it 's left child  has same value ; If curr node and it 's right child  has same value ; Function to find length of longest same value path ; Helper function that allocates a new node with the given data and null left and right pointers . ; Driver code ; Let us cona Binary Tree 4 / \ 4 4 / \ \ 4 9 5
class GFG { static int ans ; static class Node { int val ; Node left , right ; } ; static int length ( Node node ) { if ( node == null ) return 0 ; int left = length ( node . left ) ; int right = length ( node . right ) ; int Leftmax = 0 , Rightmax = 0 ; if ( node . left != null && node . left . val == node . val ) Leftmax += left + 1 ; if ( node . right != null && node . right . val == node . val ) Rightmax += right + 1 ; ans = Math . max ( ans , Leftmax + Rightmax ) ; return Math . max ( Leftmax , Rightmax ) ; } static int longestSameValuePath ( Node root ) { ans = 0 ; length ( root ) ; return ans ; } static Node newNode ( int data ) { Node temp = new Node ( ) ; temp . val = data ; temp . left = temp . right = null ; return temp ; } public static void main ( String [ ] args ) { Node root = null ; root = newNode ( 4 ) ; root . left = newNode ( 4 ) ; root . right = newNode ( 4 ) ; root . left . left = newNode ( 4 ) ; root . left . right = newNode ( 9 ) ; root . right . right = newNode ( 5 ) ; System . out . print ( longestSameValuePath ( root ) ) ; } }
Check if edit distance between two strings is one | Java program to check if given two strings are at distance one . ; Returns true if edit distance between s1 and s2 is one , else false ; Find lengths of given strings ; If difference between lengths is more than 1 , then strings can 't  be at one distance ; int count = 0 ; Count of edits ; If current characters don 't match ; If length of one string is more , then only possible edit is to remove a character ; else Iflengths of both strings is same ; Increment count of edits ; else If current characters match ; If last character is extra in any string ; driver code
class GFG { static boolean isEditDistanceOne ( String s1 , String s2 ) { int m = s1 . length ( ) , n = s2 . length ( ) ; if ( Math . abs ( m - n ) > 1 ) return false ; int i = 0 , j = 0 ; while ( i < m && j < n ) { if ( s1 . charAt ( i ) != s2 . charAt ( j ) ) { if ( count == 1 ) return false ; if ( m > n ) i ++ ; else if ( m < n ) j ++ ; { i ++ ; j ++ ; } count ++ ; } { i ++ ; j ++ ; } } if ( i < m j < n ) count ++ ; return count == 1 ; } public static void main ( String [ ] args ) { String s1 = " gfg " ; String s2 = " gf " ; if ( isEditDistanceOne ( s1 , s2 ) ) System . out . print ( " Yes " ) ; else System . out . print ( " No " ) ; } }
Count of numbers from range [ L , R ] whose sum of digits is Y | Set 2 | Java program for the above approach ; Function to find the sum of digits of numbers in the range [ 0 , X ] ; Check if count of digits in a number greater than count of digits in X ; Check Iif sum of digits of a number is equal to Y ; Check if current subproblem has already been computed ; Stores count of numbers whose sum of digits is Y ; Check if the number exceeds Y or not ; Iterate over all possible values of i - th digits ; Update res ; Return res ; Utility function to count the numbers in the range [ L , R ] whose sum of digits is Y ; Base Case ; Stores numbers in the form of its equivalent String ; Stores overlapping subproblems ; Initialize dp [ ] [ ] [ ] ; Stores count of numbers in the range [ 0 , R ] ; Update str ; Initialize dp [ ] [ ] [ ] ; Stores count of numbers in the range [ 0 , L - 1 ] ; Driver Code
import java . util . * ; class GFG { static final int M = 1000 ; static int cntNum ( String X , int i , int sum , int tight , int dp [ ] [ ] [ ] ) { if ( i >= X . length ( ) sum < 0 ) { if ( sum == 0 ) { return 1 ; } return 0 ; } if ( dp [ sum ] [ i ] [ tight ] != - 1 ) { return dp [ sum ] [ i ] [ tight ] ; } int res = 0 ; int end = tight != 0 ? X . charAt ( i ) - '0' : 9 ; for ( int j = 0 ; j <= end ; j ++ ) { res += cntNum ( X , i + 1 , sum - j , ( tight > 0 & ( j == end ) ) == true ? 1 : 0 , dp ) ; } return dp [ sum ] [ i ] [ tight ] = res ; } static int UtilCntNumRange ( int L , int R , int Y ) { if ( R == 0 && Y == 0 ) { return 1 ; } String str = String . valueOf ( R ) ; int [ ] [ ] [ ] dp = new int [ M ] [ M ] [ 2 ] ; for ( int i = 0 ; i < M ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { for ( int k = 0 ; k < 2 ; k ++ ) dp [ i ] [ j ] [ k ] = - 1 ; } } int cntR = cntNum ( str , 0 , Y , 1 , dp ) ; str = String . valueOf ( L - 1 ) ; for ( int i = 0 ; i < M ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { for ( int k = 0 ; k < 2 ; k ++ ) dp [ i ] [ j ] [ k ] = - 1 ; } } int cntL = cntNum ( str , 0 , Y , 1 , dp ) ; return ( cntR - cntL ) ; } public static void main ( String [ ] args ) { int L = 20 , R = 10000 , Y = 14 ; System . out . print ( UtilCntNumRange ( L , R , Y ) ) ; } }
Remove spaces from a given string | Java program to remove all spaces from a string ; Function to remove all spaces from a given string ; Driver Code
class GFG { static String removeSpace ( String str ) { str = str . replaceAll ( " \\ s " , " " ) ; return str ; } public static void main ( String args [ ] ) { String str = " g ▁ eeks ▁ for ▁ ge ▁ eeks ▁ " ; System . out . println ( removeSpace ( str ) ) ; } }
Given a binary string , count number of substrings that start and end with 1. | A simple C ++ program to count number of substrings starting and ending with 1 ; Initialize result ; Pick a starting point ; Search for all possible ending point ; Driver program to test the above function
class CountSubString { int countSubStr ( char str [ ] , int n ) { int res = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( str [ i ] == '1' ) { for ( int j = i + 1 ; j < n ; j ++ ) { if ( str [ j ] == '1' ) res ++ ; } } } return res ; } public static void main ( String [ ] args ) { CountSubString count = new CountSubString ( ) ; String string = "00100101" ; char str [ ] = string . toCharArray ( ) ; int n = str . length ; System . out . println ( count . countSubStr ( str , n ) ) ; } }
An in | Java implementation of above approach ; A utility function to reverse String str [ low . . high ] ; Cycle leader algorithm to move all even positioned elements at the end . ; odd index ; even index ; Keep the back - up of element at new position ; The main function to transform a String . This function mainly uses cycleLeader ( ) to transform ; Step 1 : Find the largest prefix subarray of the form 3 ^ k + 1 ; Step 2 : Apply cycle leader algorithm for the largest subarrau ; Step 4.1 : Reverse the second half of first subarray ; Step 4.2 : Reverse the first half of second sub - String . ; Step 4.3 Reverse the second half of first sub - String and first half of second sub - String together ; Increase the length of first subarray ; Driver code
import java . util . * ; class GFG { static char [ ] str ; static void reverse ( int low , int high ) { while ( low < high ) { char t = str [ low ] ; str [ low ] = str [ high ] ; str [ high ] = t ; ++ low ; -- high ; } } static void cycleLeader ( int shift , int len ) { int j ; char item ; for ( int i = 1 ; i < len ; i *= 3 ) { j = i ; item = str [ j + shift ] ; do { if ( j % 2 == 1 ) j = len / 2 + j / 2 ; else j /= 2 ; char t = str [ j + shift ] ; str [ j + shift ] = item ; item = t ; } while ( j != i ) ; } } static void moveNumberToSecondHalf ( ) { int k , lenFirst ; int lenRemaining = str . length ; int shift = 0 ; while ( lenRemaining > 0 ) { k = 0 ; while ( Math . pow ( 3 , k ) + 1 <= lenRemaining ) k ++ ; lenFirst = ( int ) Math . pow ( 3 , k - 1 ) + 1 ; lenRemaining -= lenFirst ; cycleLeader ( shift , lenFirst ) ; reverse ( shift / 2 , shift - 1 ) ; reverse ( shift , shift + lenFirst / 2 - 1 ) ; reverse ( shift / 2 , shift + lenFirst / 2 - 1 ) ; shift += lenFirst ; } } public static void main ( String [ ] args ) { String st = " a1b2c3d4e5f6g7" ; str = st . toCharArray ( ) ; moveNumberToSecondHalf ( ) ; System . out . print ( str ) ; } }
Remove nodes on root to leaf paths of length < K | Class containing left and right child of current node and key value ; Utility method that actually removes the nodes which are not on the pathLen >= k . This method can change the root as well . ; Base condition ; Traverse the tree in postorder fashion so that if a leaf node path length is shorter than k , then that node and all of its descendants till the node which are not on some other path are removed . ; If root is a leaf node and it 's level is less than k then  remove this node.  This goes up and check for the ancestor nodes also for the  same condition till it finds a node which is a part of other  path(s) too. ; Return root ; ; Method which calls the utitlity method to remove the short path nodes . ; Method to print the tree in inorder fashion . ; Driver program to test for samples
class Node { int data ; Node left , right ; public Node ( int item ) { data = item ; left = right = null ; } } class BinaryTree { Node root ; Node removeShortPathNodesUtil ( Node node , int level , int k ) { if ( node == null ) return null ; node . left = removeShortPathNodesUtil ( node . left , level + 1 , k ) ; node . right = removeShortPathNodesUtil ( node . right , level + 1 , k ) ; if ( node . left == null && node . right == null && level < k ) return null ; return node ; } Node removeShortPathNodes ( Node node , int k ) { int pathLen = 0 ; return removeShortPathNodesUtil ( node , 1 , k ) ; } void printInorder ( Node node ) { if ( node != null ) { printInorder ( node . left ) ; System . out . print ( node . data + " ▁ " ) ; printInorder ( node . right ) ; } } public static void main ( String args [ ] ) { BinaryTree tree = new BinaryTree ( ) ; int k = 4 ; tree . root = new Node ( 1 ) ; tree . root . left = new Node ( 2 ) ; tree . root . right = new Node ( 3 ) ; tree . root . left . left = new Node ( 4 ) ; tree . root . left . right = new Node ( 5 ) ; tree . root . left . left . left = new Node ( 7 ) ; tree . root . right . right = new Node ( 6 ) ; tree . root . right . right . left = new Node ( 8 ) ; System . out . println ( " The ▁ inorder ▁ traversal ▁ of ▁ original ▁ tree ▁ is ▁ : ▁ " ) ; tree . printInorder ( tree . root ) ; Node res = tree . removeShortPathNodes ( tree . root , k ) ; System . out . println ( " " ) ; System . out . println ( " The ▁ inorder ▁ traversal ▁ of ▁ modified ▁ tree ▁ is ▁ : ▁ " ) ; tree . printInorder ( res ) ; } }
Remove duplicates from a given string | Java program to remove duplicate character from character array and print in sorted order ; Create a set using String characters excluding ' \0' ; HashSet doesn 't allow repetition of elements ; Driver code
import java . util . * ; class GFG { static void removeDuplicate ( char str [ ] , int n ) { HashSet < Character > s = new LinkedHashSet < > ( n - 1 ) ; for ( char x : str ) s . add ( x ) ; for ( char x : s ) System . out . print ( x ) ; } public static void main ( String [ ] args ) { char str [ ] = " geeksforgeeks " . toCharArray ( ) ; int n = str . length ; removeDuplicate ( str , n ) ; } }
Check if K can be obtained by performing arithmetic operations on any permutation of an Array | Java program for above approach ; Function that finds the string of possible combination of operations ; If only one number left then check for result ; If resultant value is K ; Else return 0 ; Choose all combination of numbers and operators and operate them ; Choose the first two and operate it with ' + ' ; Place it to 0 th position ; Place ( n - 1 ) th element on 1 st position ; Evaluate the expression with current combination ; Now , we have N - 1 elements ; Try ' - ' operation ; Evaluate the expression with current combination ; Try reverse ' - ' ; Evaluate the expression with current combination ; Try ' * ' operation ; Evaluate the expression with current combination ; Try ' / ' ; Evaluate the expression with current combination ; Try reverse ' / ' ; Evaluate the expression with current combination ; Backtracking Step ; Return 0 if there doesnt exist any combination that gives K ; Function that finds the possible combination of operation to get the resultant value K ; Store the resultant operation ; Function call ; Driver Code ; Given array arr [ ] ; Resultant value K ; Function call
class GFG { static boolean find ( double [ ] v , int n , double dest , String s ) { if ( n == 1 ) { if ( Math . abs ( v [ 0 ] - dest ) <= 0.0000001 ) { System . out . println ( s + String . valueOf ( ( int ) dest ) + " ▁ " ) ; return true ; } return false ; } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { double a = v [ i ] , b = v [ j ] ; String p = s ; v [ i ] = a + b ; v [ j ] = v [ n - 1 ] ; s = ( s + String . valueOf ( ( int ) a ) + ' + ' + String . valueOf ( ( int ) b ) + " ▁ = > ▁ " ) ; if ( find ( v , n - 1 , dest , s ) ) return true ; s = p ; v [ i ] = a - b ; v [ j ] = v [ n - 1 ] ; s = ( s + String . valueOf ( ( int ) a ) + ' - ' + String . valueOf ( ( int ) b ) + " ▁ = > ▁ " ) ; if ( find ( v , n - 1 , dest , s ) ) return true ; s = p ; v [ i ] = b - a ; v [ j ] = v [ n - 1 ] ; s = ( s + String . valueOf ( ( int ) b ) + ' - ' + String . valueOf ( ( int ) a ) + " ▁ = > ▁ " ) ; if ( find ( v , n - 1 , dest , s ) ) return true ; s = p ; v [ i ] = a * b ; v [ j ] = v [ n - 1 ] ; s = ( s + String . valueOf ( ( int ) a ) + ' * ' + String . valueOf ( ( int ) b ) + " ▁ = > ▁ " ) ; if ( find ( v , n - 1 , dest , s ) ) return true ; s = p ; if ( b != 0 ) { v [ i ] = a / b ; v [ j ] = v [ n - 1 ] ; s = ( s + String . valueOf ( ( int ) a ) + ' / ' + String . valueOf ( ( int ) b ) + " ▁ = > ▁ " ) ; if ( find ( v , n - 1 , dest , s ) ) return true ; } s = p ; if ( a != 0 ) { v [ i ] = b / a ; v [ j ] = v [ n - 1 ] ; s = ( s + String . valueOf ( ( int ) b ) + ' / ' + String . valueOf ( ( int ) a ) + " ▁ = > ▁ " ) ; if ( find ( v , n - 1 , dest , s ) ) return true ; } s = p ; v [ i ] = a ; v [ j ] = b ; } } return false ; } static void checkPossibleOperation ( double [ ] arr , double K ) { String s = " " ; if ( ! find ( arr , arr . length , K , s ) ) { System . out . println ( " - 1" ) ; } } public static void main ( String [ ] args ) { double [ ] arr = { 2 , 0 , 0 , 2 } ; double K = 4 ; checkPossibleOperation ( arr , K ) ; } }