codeparrot/xlcost-text-to-code huggingface dataset:
Evaluate an array expression with numbers , + and | C # program to find sum of given array of string type in integer form ; Function to find the sum of given array ; if string is empty ; parseInt function to convert string into integer ; parseInt function to convert string into integer ; Find operator ; If operator is equal to ' + ' , add value in sum variable else subtract ; Driver code
using System ; class GFG { public static int calculateSum ( string [ ] arr , int n ) { if ( n == 0 ) return 0 ; string s = arr [ 0 ] ; int value = int . Parse ( s ) ; int sum = value ; for ( int i = 2 ; i < n ; i = i + 2 ) { s = arr [ i ] ; value = int . Parse ( s ) ; char operation = arr [ i - 1 ] [ 0 ] ; if ( operation == ' + ' ) sum += value ; else sum -= value ; } return sum ; } public static void Main ( ) { string [ ] arr = { "3" , " + " , "4" , " - " , "7" , " + " , "13" } ; int n = arr . Length ; Console . Write ( calculateSum ( arr , n ) ) ; } }
Check if two strings have a common substring | C # program to check if two strings have common substring ; function to return true if strings have common substring and no if strings have no common substring ; vector for storing character occurrences ; increment vector index for every character of str1 ; checking common substring of str2 in str1 ; Driver code
using System ; class GFG { static int MAX_CHAR = 26 ; static bool twoStrings ( String s1 , String s2 ) { bool [ ] v = new bool [ MAX_CHAR ] ; for ( int i = 0 ; i < MAX_CHAR ; i ++ ) v [ i ] = false ; for ( int i = 0 ; i < s1 . Length ; i ++ ) v [ s1 [ i ] - ' a ' ] = true ; for ( int i = 0 ; i < s2 . Length ; i ++ ) if ( v [ s2 [ i ] - ' a ' ] ) return true ; return false ; } public static void Main ( ) { String str1 = " hello " ; String str2 = " world " ; if ( twoStrings ( str1 , str2 ) ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } }
String with maximum number of unique characters | C # code to find the largest string ; Function to find string with maximum number of unique characters . ; Index of string with maximum unique characters ; iterate through all strings ; array indicating any alphabet included or not included ; count number of unique alphabets in each string ; keep track of maximum number of alphabets ; print result ; Driver code
using System ; class GFG { public static void LargestString ( string [ ] na ) { int N = na . Length ; int [ ] c = new int [ N ] ; int m = 0 ; for ( int j = 0 ; j < N ; j ++ ) { bool [ ] character = new bool [ 26 ] ; for ( int k = 0 ; k < na [ j ] . Length ; k ++ ) { int x = na [ j ] [ k ] - ' A ' ; if ( ( na [ j ] [ k ] != ' ▁ ' ) && ( character [ x ] == false ) ) { c [ j ] ++ ; character [ x ] = true ; } } if ( c [ j ] > c [ m ] ) m = j ; } Console . Write ( na [ m ] ) ; } public static void Main ( ) { string [ ] na = { " BOB " , " A ▁ AB ▁ C ▁ JOHNSON " , " ANJALI " , " ASKRIT " , " ARMAN ▁ MALLIK " } ; LargestString ( na ) ; } }
Program for length of the longest word in a sentence | C # program to find the number of charters in the longest word in the sentence . ; Driver code
using System ; class GFG { static int LongestWordLength ( string str ) { String [ ] words = str . Split ( ' ▁ ' ) ; int length = 0 ; for ( int i = 0 ; i < words . Length ; i ++ ) { if ( length < words [ i ] . Length ) { length = words [ i ] . Length ; } } return length ; } static void Main ( ) { string str = " I ▁ am ▁ an ▁ intern ▁ at ▁ geeksforgeeks " ; Console . Write ( LongestWordLength ( str ) ) ; } }
Morse Code Implementation | C # program to demonstrate Morse code ; function to encode a alphabet as Morse code ; refer to the Morse table image attached in the article ; for space ; character by character print Morse code ; Driver code
using System ; class GFG { static string morseEncode ( char x ) { switch ( x ) { case ' a ' : return " . - " ; case ' b ' : return " - . . . " ; case ' c ' : return " - . - . " ; case ' d ' : return " - . . " ; case ' e ' : return " . " ; case ' f ' : return " . . - . " ; case ' g ' : return " - - . " ; case ' h ' : return " . . . . " ; case ' i ' : return " . . " ; case ' j ' : return " . - - - " ; case ' k ' : return " - . - " ; case ' l ' : return " . - . . " ; case ' m ' : return " - - " ; case ' n ' : return " - . " ; case ' o ' : return " - - - " ; case ' p ' : return " . - - . " ; case ' q ' : return " - - . - " ; case ' r ' : return " . - . " ; case ' s ' : return " . . . " ; case ' t ' : return " - " ; case ' u ' : return " . . - " ; case ' v ' : return " . . . - " ; case ' w ' : return " . - - " ; case ' x ' : return " - . . - " ; case ' y ' : return " - . - - " ; case ' z ' : return " - - . . " ; case '1' : return " . - - - - " ; case '2' : return " . . - - - " ; case '3' : return " . . . - - " ; case '4' : return " . . . . - " ; case '5' : return " . . . . . " ; case '6' : return " - . . . . " ; case '7' : return " - - . . . " ; case '8' : return " - - - . . " ; case '9' : return " - - - - . " ; case '0' : return " - - - - - " ; } return " " ; } static void morseCode ( string s ) { for ( int i = 0 ; i < s . Length ; i ++ ) Console . Write ( morseEncode ( s [ i ] ) ) ; Console . WriteLine ( ) ; } public static void Main ( ) { string s = " geeksforgeeks " ; morseCode ( s ) ; } }
Polybius Square Cipher | C # Program to implement polybius cipher ; Function to display polybius cipher text ; convert each character to its encrypted code ; finding row of the table ; finding column of the table ; if character is ' k ' ; if character is greater than ' j ' ; Driver code ; print the cipher of "geeksforgeeks
using System ; class GFG { static void polybiusCipher ( string s ) { int row , col ; for ( int i = 0 ; i < s . Length ; i ++ ) { row = ( int ) Math . Floor ( ( s [ i ] - ' a ' ) / 5.0 ) + 1 ; col = ( ( s [ i ] - ' a ' ) % 5 ) + 1 ; if ( s [ i ] == ' k ' ) { row = row - 1 ; col = 5 - col + 1 ; } else if ( s [ i ] >= ' j ' ) { if ( col == 1 ) { col = 6 ; row = row - 1 ; } col = col - 1 ; } Console . Write ( row + " " + col ) ; } Console . WriteLine ( ) ; } static void Main ( ) { string s = " geeksforgeeks " ; polybiusCipher ( s ) ; } }
Minimum removal to make palindrome permutation | C # Program to find minimum number of removal to make any permutation of the string a palindrome ; function to find minimum removal of characters ; hash to store frequency of each character ; to set hash array to zeros ; count frequency of each character ; count the odd frequency characters ; if count is - 1 return 0 otherwise return count ; Driver code
using System ; class GFG { static int MAX_CHAR = 26 ; static int minRemoval ( string str ) { int [ ] hash = new int [ MAX_CHAR ] ; for ( int i = 0 ; i < MAX_CHAR ; i ++ ) hash [ i ] = 0 ; for ( int i = 0 ; i < str . Length ; i ++ ) hash [ str [ i ] - ' a ' ] ++ ; int count = 0 ; for ( int i = 0 ; i < MAX_CHAR ; i ++ ) if ( hash [ i ] % 2 == 1 ) count ++ ; return ( count == 0 ) ? 0 : count - 1 ; } public static void Main ( ) { string str = " geeksforgeeks " ; Console . Write ( minRemoval ( str ) ) ; } }
Union | C # program to implement Union - Find with union by rank and path compression ; Arr to represent parent of index i ; Size to represent the number of nodes in subgxrph rooted at index i ; set parent of every node to itself and size of node to one ; Each time we follow a path , find function compresses it further until the path length is greater than or equal to 1. ; while we reach a node whose parent is equal to itself ; Skip one level ; Move to the new level ; A function that does union of two nodes x and y where xr is root node of x and yr is root node of y ; Make yr parent of xr ; Make xr parent of yr ; The main function to check whether a given graph contains cycle or not ; Itexrte through all edges of graph , find nodes connecting them . If root nodes of both are same , then there is cycle in graph . ; find root of i ; find root of adj [ i ] [ j ] ; If same parent ; Make them connect ; Driver Code ; Initialize the values for array Arr and Size ; Adjacency list for graph ; call is_cycle to check if it contains cycle
using System ; using System . Collections . Generic ; class GFG { static int MAX_VERTEX = 101 ; static int [ ] Arr = new int [ MAX_VERTEX ] ; static int [ ] size = new int [ MAX_VERTEX ] ; static void initialize ( int n ) { for ( int i = 0 ; i <= n ; i ++ ) { Arr [ i ] = i ; size [ i ] = 1 ; } } static int find ( int i ) { while ( Arr [ i ] != i ) { Arr [ i ] = Arr [ Arr [ i ] ] ; i = Arr [ i ] ; } return i ; } static void _union ( int xr , int yr ) { if ( size [ xr ] < size [ yr ] ) { Arr [ xr ] = Arr [ yr ] ; size [ yr ] += size [ xr ] ; } else { Arr [ yr ] = Arr [ xr ] ; size [ xr ] += size [ yr ] ; } } static int isCycle ( List < int > [ ] adj , int V ) { for ( int i = 0 ; i < V ; i ++ ) { for ( int j = 0 ; j < adj [ i ] . Count ; j ++ ) { int x = find ( i ) ; int y = find ( adj [ i ] [ j ] ) ; if ( x == y ) return 1 ; _union ( x , y ) ; } } return 0 ; } public static void Main ( String [ ] args ) { int V = 3 ; initialize ( V ) ; List < int > [ ] adj = new List < int > [ V ] ; for ( int i = 0 ; i < V ; i ++ ) adj [ i ] = new List < int > ( ) ; adj [ 0 ] . Add ( 1 ) ; adj [ 0 ] . Add ( 2 ) ; adj [ 1 ] . Add ( 2 ) ; if ( isCycle ( adj , V ) == 1 ) Console . Write ( " Graph ▁ contains ▁ Cycle . STRNEWLINE " ) ; else Console . Write ( " Graph ▁ does ▁ not ▁ contain ▁ Cycle . STRNEWLINE " ) ; } }
Queries for frequencies of characters in substrings | C # program to find occurrence of character in substring l to r ; To store count of all character ; To pre - process string from 0 to size of string ; Store occurrence of character i ; Store occurrence o all character upto i ; To return occurrence of character in range l to r ; Return occurrence of character from 0 to r minus its occurrence from 0 to l ; Driver code
using System ; class GFG { static int MAX_LEN = 1005 ; static int MAX_CHAR = 26 ; static int [ , ] cnt = new int [ MAX_LEN , MAX_CHAR ] ; static void preProcess ( string s ) { int n = s . Length ; for ( int i = 0 ; i < n ; i ++ ) cnt [ i , s [ i ] - ' a ' ] ++ ; for ( int i = 1 ; i < n ; i ++ ) { for ( int j = 0 ; j < 26 ; j ++ ) cnt [ i , j ] += cnt [ i - 1 , j ] ; } } static int findCharFreq ( int l , int r , char c ) { return ( cnt [ r , c - 97 ] - cnt [ l , c - 97 ] ) ; } public static void Main ( string [ ] args ) { string s = " geeksforgeeks " ; int Q = 4 ; preProcess ( s ) ; Console . WriteLine ( findCharFreq ( 0 , 5 , ' e ' ) ) ; Console . WriteLine ( findCharFreq ( 2 , 6 , ' f ' ) ) ; Console . WriteLine ( findCharFreq ( 4 , 7 , ' m ' ) ) ; Console . WriteLine ( findCharFreq ( 0 , 12 , ' e ' ) ) ; } }
Longest Uncommon Subsequence | C # program to find longest uncommon subsequence using naive method . ; function to calculate length of longest uncommon subsequence ; Case 1 : If strings are equal ; for case 2 and case 3 ; Driver code ; input strings
using System ; class GfG { static int findLUSlength ( String a , String b ) { if ( a . Equals ( b ) == true ) return 0 ; return Math . Max ( a . Length , b . Length ) ; } public static void Main ( ) { String a = " abcdabcd " , b = " abcabc " ; Console . Write ( findLUSlength ( a , b ) ) ; } }
Interchanging first and second halves of strings | C # code to create two new strings by swapping first and second halves ; Function to concatenate two different halves of given strings ; Creating new strings by exchanging the first half of a and b . ; Driver Code ; Calling function
using System ; class GFG { static void swapTwoHalves ( string a , string b ) { int la = a . Length ; int lb = b . Length ; string c = a . Substring ( 0 , la / 2 ) + b . Substring ( lb / 2 , lb / 2 + 1 ) ; string d = b . Substring ( 0 , lb / 2 ) + a . Substring ( la / 2 , la / 2 ) ; Console . Write ( c + " STRNEWLINE " + d + " STRNEWLINE " ) ; } static void Main ( ) { string a = " remuneration " ; string b = " day " ; swapTwoHalves ( a , b ) ; } }
Merge two strings in chunks of given size | C # program to merge n number of strings ; Function performing the calculations ; Length of string a ; Length f string b ; Pointers for string a and string b ; pa and pb denote the number of characters a and b extracted ; If entire substring of length k can be extracted ; If the remaining string is of length less than k ; If the string has been traversed ; If entire substring of length k can be extracted ; If the remaining string is of length less than k ; If the string has been traversed ; Driver Code
using System ; class GFG { static void solve ( string a , string b , int k ) { string s = " " ; int la = a . Length ; int lb = b . Length ; int l = la + lb ; int indexa = 0 , indexb = 0 ; while ( l > 0 ) { int pa = 0 , pb = 0 ; if ( la - indexa >= k ) { s = s + a . Substring ( indexa , k ) ; indexa = indexa + k ; pa = k ; } else if ( la - indexa < k && la - indexa > 0 ) { s = s + a . Substring ( indexa , la - indexa ) ; pa = la - indexa ; indexa = la ; } else if ( indexa >= la ) pa = 0 ; if ( lb - indexb >= k ) { s = s + b . Substring ( indexb , k ) ; pb = k ; indexb = indexb + k ; } else if ( lb - indexb < k && lb - indexb > 0 ) { s = s + b . Substring ( indexb , lb - indexb ) ; pb = lb - indexb ; indexb = lb ; } else if ( indexb >= lb ) pb = 0 ; l = l - pa - pb ; } Console . Write ( s ) ; } static void Main ( ) { string a = " determination " , b = " stance " ; int k = 3 ; solve ( a , b , k ) ; } }
Longest sub | C # implementation to find the length of the longest substring having frequency of each character less than equal to k ; function to find the length of the longest substring having frequency of each character less than equal to k ; hash table to store frequency of each table ; ' start ' index of the current substring ; to store the maximum length ; traverse the string ' str ' ; get the current character as ' ch ' ; increase frequency of ' ch ' in ' freq [ ] ' ; if frequency of ' ch ' becomes more than ' k ' ; update ' maxLen ' ; decrease frequency of each character as they are encountered from the ' start ' index until frequency of ' ch ' is greater than ' k ' ; decrement frequency by '1' ; increment ' start ' ; update maxLen ; required length ; Driver function
using System ; class GfG { public static int SIZE = 26 ; public static int longSubstring ( String str1 , int k ) { int [ ] freq = new int [ SIZE ] ; char [ ] str = str1 . ToCharArray ( ) ; int start = 0 ; int maxLen = 0 ; char ch ; int n = str1 . Length ; for ( int i = 0 ; i < n ; i ++ ) { ch = str [ i ] ; freq [ ch - ' a ' ] ++ ; if ( freq [ ch - ' a ' ] > k ) { if ( maxLen < ( i - start ) ) maxLen = i - start ; while ( freq [ ch - ' a ' ] > k ) { freq [ str [ start ] - ' a ' ] -- ; start ++ ; } } } if ( maxLen < ( n - start ) ) maxLen = n - start ; return maxLen ; } public static void Main ( ) { String str = " babcaag " ; int k = 1 ; Console . Write ( " Length ▁ = ▁ " + longSubstring ( str , k ) ) ; } }
Magical Indices in an array | C # program to find number of magical indices in the given array . ; Function to count number of magical indices . ; Array to store parent node of traversal . ; Array to determine whether current node is already counted in the cycle . ; Initialize the arrays . ; Check if current node is already traversed or not . If node is not traversed yet then parent value will be - 1. ; Traverse the graph until an already visited node is not found . ; Check parent value to ensure a cycle is present . ; Count number of nodes in the cycle . ; Driver code
using System ; using System . Collections . Generic ; using System . Linq ; class GFG { static int solve ( int [ ] A , int n ) { int i , cnt = 0 , j ; int [ ] parent = new int [ n + 1 ] ; int [ ] vis = new int [ n + 1 ] ; for ( i = 0 ; i < n + 1 ; i ++ ) { parent [ i ] = - 1 ; vis [ i ] = 0 ; } for ( i = 0 ; i < n ; i ++ ) { j = i ; if ( parent [ j ] == - 1 ) { while ( parent [ j ] == - 1 ) { parent [ j ] = i ; j = ( j + A [ j ] + 1 ) % n ; } if ( parent [ j ] == i ) { while ( vis [ j ] == 0 ) { vis [ j ] = 1 ; cnt ++ ; j = ( j + A [ j ] + 1 ) % n ; } } } } return cnt ; } public static void Main ( ) { int [ ] A = { 0 , 0 , 0 , 2 } ; int n = A . Length ; Console . WriteLine ( solve ( A , n ) ) ; } }
Level order traversal with direction change after every two levels | C # program to print Zig - Zag traversal in groups of size 2. ; A Binary Tree Node ; Utility function to create a new tree node ; Function to print the level order of given binary tree . Direction of printing level order traversal of binary tree changes after every two levels ; Run this while loop till queue got empty ; For printing nodes from right to left , push the nodes to stack instead of printing them . ; for printing the nodes in order from right to left ; Change the direction of traversal . ; Driver code ; Let us create binary tree
using System ; using System . Collections . Generic ; public class GFG { static readonly int LEFT = 0 ; static readonly int RIGHT = 1 ; static int ChangeDirection ( int Dir ) { Dir = 1 - Dir ; return Dir ; } public class node { public int data ; public node left , right ; } ; static node newNode ( int data ) { node temp = new node ( ) ; temp . data = data ; temp . left = temp . right = null ; return temp ; } static void modifiedLevelOrder ( node root ) { if ( root == null ) return ; int dir = LEFT ; node temp ; Queue < node > Q = new Queue < node > ( ) ; Stack < node > S = new Stack < node > ( ) ; S . Push ( root ) ; while ( Q . Count != 0 S . Count != 0 ) { while ( S . Count != 0 ) { temp = S . Peek ( ) ; S . Pop ( ) ; Console . Write ( temp . data + " ▁ " ) ; if ( dir == LEFT ) { if ( temp . left != null ) Q . Enqueue ( temp . left ) ; if ( temp . right != null ) Q . Enqueue ( temp . right ) ; } else { if ( temp . right != null ) Q . Enqueue ( temp . right ) ; if ( temp . left != null ) Q . Enqueue ( temp . left ) ; } } Console . WriteLine ( ) ; while ( Q . Count != 0 ) { temp = Q . Peek ( ) ; Q . Dequeue ( ) ; Console . Write ( temp . data + " ▁ " ) ; if ( dir == LEFT ) { if ( temp . left != null ) S . Push ( temp . left ) ; if ( temp . right != null ) S . Push ( temp . right ) ; } else { if ( temp . right != null ) S . Push ( temp . right ) ; if ( temp . left != null ) S . Push ( temp . left ) ; } } Console . WriteLine ( ) ; dir = ChangeDirection ( dir ) ; } } public static void Main ( String [ ] args ) { node root = newNode ( 1 ) ; root . left = newNode ( 2 ) ; root . right = newNode ( 3 ) ; root . left . left = newNode ( 4 ) ; root . left . right = newNode ( 5 ) ; root . right . left = newNode ( 6 ) ; root . right . right = newNode ( 7 ) ; root . left . left . left = newNode ( 8 ) ; root . left . left . right = newNode ( 9 ) ; root . left . right . left = newNode ( 3 ) ; root . left . right . right = newNode ( 1 ) ; root . right . left . left = newNode ( 4 ) ; root . right . left . right = newNode ( 2 ) ; root . right . right . left = newNode ( 7 ) ; root . right . right . right = newNode ( 2 ) ; root . left . right . left . left = newNode ( 16 ) ; root . left . right . left . right = newNode ( 17 ) ; root . right . left . right . left = newNode ( 18 ) ; root . right . right . left . right = newNode ( 19 ) ; modifiedLevelOrder ( root ) ; } }
Insertion in a Binary Tree in level order | C # program to insert element in binary tree ; A binary tree node has key , pointer to left child and a pointer to right child ; constructor ; Inorder traversal of a binary tree ; function to insert element in binary tree ; Do level order traversal until we find an empty place . ; Driver code
using System ; using System . Collections . Generic ; class GFG { public class Node { public int key ; public Node left , right ; public Node ( int key ) { this . key = key ; left = null ; right = null ; } } static Node root ; static void inorder ( Node temp ) { if ( temp == null ) return ; inorder ( temp . left ) ; Console . Write ( temp . key + " ▁ " ) ; inorder ( temp . right ) ; } static void insert ( Node temp , int key ) { if ( temp == null ) { root = new Node ( key ) ; return ; } Queue < Node > q = new Queue < Node > ( ) ; q . Enqueue ( temp ) ; while ( q . Count != 0 ) { temp = q . Peek ( ) ; q . Dequeue ( ) ; if ( temp . left == null ) { temp . left = new Node ( key ) ; break ; } else q . Enqueue ( temp . left ) ; if ( temp . right == null ) { temp . right = new Node ( key ) ; break ; } else q . Enqueue ( temp . right ) ; } } public static void Main ( String [ ] args ) { root = new Node ( 10 ) ; root . left = new Node ( 11 ) ; root . left . left = new Node ( 7 ) ; root . right = new Node ( 9 ) ; root . right . left = new Node ( 15 ) ; root . right . right = new Node ( 8 ) ; Console . Write ( " Inorder ▁ traversal ▁ before ▁ insertion : " ) ; inorder ( root ) ; int key = 12 ; insert ( root , key ) ; Console . Write ( " STRNEWLINE Inorder ▁ traversal ▁ after ▁ insertion : " ) ; inorder ( root ) ; } }
Tug of War | C # program for Tug of war ; function that tries every possible solution by calling itself recursively ; checks whether the it is going out of bound ; checks that the numbers of elements left are not less than the number of elements required to form the solution ; consider the cases when current element is not included in the solution ; add the current element to the solution ; checks if a solution is formed ; checks if the solution formed is better than the best solution so far ; consider the cases where current element is included in the solution ; removes current element before returning to the caller of this function ; main function that generate an arr ; the boolean array that contains the inclusion and exclusion of an element in current set . The number excluded automatically form the other set ; The inclusion / exclusion array for final solution ; Find the solution using recursive function TOWUtil ( ) ; Print the solution ; Driver Code
using System ; class GFG { public int min_diff ; void TOWUtil ( int [ ] arr , int n , Boolean [ ] curr_elements , int no_of_selected_elements , Boolean [ ] soln , int sum , int curr_sum , int curr_position ) { if ( curr_position == n ) return ; if ( ( n / 2 - no_of_selected_elements ) > ( n - curr_position ) ) return ; TOWUtil ( arr , n , curr_elements , no_of_selected_elements , soln , sum , curr_sum , curr_position + 1 ) ; no_of_selected_elements ++ ; curr_sum = curr_sum + arr [ curr_position ] ; curr_elements [ curr_position ] = true ; if ( no_of_selected_elements == n / 2 ) { if ( Math . Abs ( sum / 2 - curr_sum ) < min_diff ) { min_diff = Math . Abs ( sum / 2 - curr_sum ) ; for ( int i = 0 ; i < n ; i ++ ) soln [ i ] = curr_elements [ i ] ; } } else { TOWUtil ( arr , n , curr_elements , no_of_selected_elements , soln , sum , curr_sum , curr_position + 1 ) ; } curr_elements [ curr_position ] = false ; } void tugOfWar ( int [ ] arr ) { int n = arr . Length ; Boolean [ ] curr_elements = new Boolean [ n ] ; Boolean [ ] soln = new Boolean [ n ] ; min_diff = int . MaxValue ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += arr [ i ] ; curr_elements [ i ] = soln [ i ] = false ; } TOWUtil ( arr , n , curr_elements , 0 , soln , sum , 0 , 0 ) ; Console . Write ( " The ▁ first ▁ subset ▁ is : ▁ " ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( soln [ i ] == true ) Console . Write ( arr [ i ] + " ▁ " ) ; } Console . Write ( " STRNEWLINE The ▁ second ▁ subset ▁ is : ▁ " ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( soln [ i ] == false ) Console . Write ( arr [ i ] + " ▁ " ) ; } } public static void Main ( String [ ] args ) { int [ ] arr = { 23 , 45 , - 34 , 12 , 0 , 98 , - 99 , 4 , 189 , - 1 , 4 } ; GFG a = new GFG ( ) ; a . tugOfWar ( arr ) ; } }