dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . util . * ; class GFG { static int maxCrossingSum ( int arr [ ] , int l , int m , int h ) { int sum = 0 ; int left_sum = Integer . MIN_VALUE ; for ( int i = m ; i >= l ; i -- ) { sum = sum + arr [ i ] ; if ( sum > left_sum ) left_sum = sum ; } sum = 0 ; int right_sum = Integer . MIN_VALUE ; for ( int i = m + 1 ; i <= h ; i ++ ) { sum = sum + arr [ i ] ; if ( sum > right_sum ) right_sum = sum ; } return Math . max ( left_sum + right_sum , Math . max ( left_sum , right_sum ) ) ; } static int maxSubArraySum ( int arr [ ] , int l , int h ) { if ( l == h ) return arr [ l ] ; int m = ( l + h ) / 2 ; return Math . max ( Math . max ( maxSubArraySum ( arr , l , m ) , maxSubArraySum ( arr , m + 1 , h ) ) , maxCrossingSum ( arr , l , m , h ) ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 3 , 4 , 5 , 7 } ; int n = arr . length ; int max_sum = maxSubArraySum ( arr , 0 , n - 1 ) ; System . out . println ( " Maximum ▁ contiguous ▁ sum ▁ is ▁ " + max_sum ) ; } }

Index/key variables: i, l
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int max ( int x , int y ) { return ( x > y ) ? x : y ; } static class Node { int data ; Node left , right ; } ; static int LISS ( Node root ) { if ( root == null ) return 0 ; int size_excl = LISS ( root . left ) + LISS ( root . right ) ; int size_incl = 1 ; if ( root . left != null ) size_incl += LISS ( root . left . left ) + LISS ( root . left . right ) ; if ( root . right != null ) size_incl += LISS ( root . right . left ) + LISS ( root . right . right ) ; return max ( size_incl , size_excl ) ; } static Node newNode ( int data ) { Node temp = new Node ( ) ; temp . data = data ; temp . left = temp . right = null ; return temp ; } public static void main ( String args [ ] ) { Node root = newNode ( 20 ) ; root . left = newNode ( 8 ) ; root . left . left = newNode ( 4 ) ; root . left . right = newNode ( 12 ) ; root . left . right . left = newNode ( 10 ) ; root . left . right . right = newNode ( 14 ) ; root . right = newNode ( 22 ) ; root . right . right = newNode ( 25 ) ; System . out . println ( " Size ▁ of ▁ the ▁ Largest " + " ▁ Independent ▁ Set ▁ is ▁ " + LISS ( root ) ) ; } }

Accumulator variables: size_incl
Class/struct names: GFG, Node
Java program:
import java . lang . * ; class GFG { static float findWater ( int i , int j , float X ) { if ( j > i ) { System . out . println ( " Incorrect ▁ Input " ) ; System . exit ( 0 ) ; } int ll = Math . round ( ( i * ( i + 1 ) ) ) ; float [ ] glass = new float [ ll + 2 ] ; int index = 0 ; glass [ index ] = X ; for ( int row = 1 ; row <= i ; ++ row ) { for ( int col = 1 ; col <= row ; ++ col , ++ index ) { X = glass [ index ] ; glass [ index ] = ( X >= 1.0f ) ? 1.0f : X ; X = ( X >= 1.0f ) ? ( X - 1 ) : 0.0f ; glass [ index + row ] += X / 2 ; glass [ index + row + 1 ] += X / 2 ; } } return glass [ ( int ) ( i * ( i - 1 ) / 2 + j - 1 ) ] ; } public static void main ( String [ ] args ) { int i = 2 , j = 2 ; float X = 2.0f ; System . out . println ( " Amount ▁ of ▁ water ▁ in ▁ jth ▁ " + " glass ▁ of ▁ ith ▁ row ▁ is : ▁ " + findWater ( i , j , X ) ) ; } }

Index/key variables: index
Iterator variables: col, row
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class Triplet { int row ; int col ; double rem_water ; Triplet ( int row , int col , double rem_water ) { this . row = row ; this . col = col ; this . rem_water = rem_water ; } } class GFG { public static double findWater ( int i , int j , int totalWater ) { double dp [ ] [ ] = new double [ i + 1 ] [ 2 * i + 1 ] ; Queue < Triplet > queue = new LinkedList < > ( ) ; queue . add ( new Triplet ( 0 , i , totalWater ) ) ; while ( ! queue . isEmpty ( ) ) { Triplet curr = queue . remove ( ) ; if ( curr . row == i ) break ; if ( dp [ curr . row ] [ curr . col ] != 1.0 ) { double rem_water = 1 - dp [ curr . row ] [ curr . col ] ; if ( rem_water > curr . rem_water ) { dp [ curr . row ] [ curr . col ] += curr . rem_water ; curr . rem_water = 0 ; } else { dp [ curr . row ] [ curr . col ] += rem_water ; curr . rem_water -= rem_water ; } } if ( curr . rem_water != 0 ) { queue . add ( new Triplet ( curr . row + 1 , curr . col - 1 , curr . rem_water / 2.0 ) ) ; queue . add ( new Triplet ( curr . row + 1 , curr . col + 1 , curr . rem_water / 2.0 ) ) ; } } return dp [ i - 1 ] [ 2 * j - 1 ] ; } public static void main ( String [ ] args ) { int i = 2 , j = 2 ; int totalWater = 2 ; System . out . print ( " Amount ▁ of ▁ water ▁ in ▁ jth ▁ glass ▁ of ▁ ith ▁ row ▁ is : " ) ; System . out . format ( " % .6f " , findWater ( i , j , totalWater ) ) ; } }

Accumulator variables: rem_water
Class/struct names: GFG, Triplet
Java program:
class Pair { int a ; int b ; public Pair ( int a , int b ) { this . a = a ; this . b = b ; } static int maxChainLength ( Pair arr [ ] , int n ) { int i , j , max = 0 ; int mcl [ ] = new int [ n ] ; for ( i = 0 ; i < n ; i ++ ) mcl [ i ] = 1 ; for ( i = 1 ; i < n ; i ++ ) for ( j = 0 ; j < i ; j ++ ) if ( arr [ i ] . a > arr [ j ] . b && mcl [ i ] < mcl [ j ] + 1 ) mcl [ i ] = mcl [ j ] + 1 ; for ( i = 0 ; i < n ; i ++ ) if ( max < mcl [ i ] ) max = mcl [ i ] ; return max ; } public static void main ( String [ ] args ) { Pair arr [ ] = new Pair [ ] { new Pair ( 5 , 24 ) , new Pair ( 15 , 25 ) , new Pair ( 27 , 40 ) , new Pair ( 50 , 60 ) } ; System . out . println ( "Length of maximum size chain is " + maxChainLength ( arr , arr . length ) ) ; } }

Index/key variables: i, j, n
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: Pair
Java program:
public class GFG { static int minPalPartion ( String str ) { int n = str . length ( ) ; int [ ] [ ] C = new int [ n ] [ n ] ; boolean [ ] [ ] P = new boolean [ n ] [ n ] ; int i , j , k , L ; for ( i = 0 ; i < n ; i ++ ) { P [ i ] [ i ] = true ; C [ i ] [ i ] = 0 ; } for ( L = 2 ; L <= n ; L ++ ) { for ( i = 0 ; i < n - L + 1 ; i ++ ) { j = i + L - 1 ; if ( L == 2 ) P [ i ] [ j ] = ( str . charAt ( i ) == str . charAt ( j ) ) ; else P [ i ] [ j ] = ( str . charAt ( i ) == str . charAt ( j ) ) && P [ i + 1 ] [ j - 1 ] ; if ( P [ i ] [ j ] == true ) C [ i ] [ j ] = 0 ; else { C [ i ] [ j ] = Integer . MAX_VALUE ; for ( k = i ; k <= j - 1 ; k ++ ) C [ i ] [ j ] = Integer . min ( C [ i ] [ j ] , C [ i ] [ k ] + C [ k + 1 ] [ j ] + 1 ) ; } } } return C [ 0 ] [ n - 1 ] ; } public static void main ( String args [ ] ) { String str = " ababbbabbababa " ; System . out . println ( " Min ▁ cuts ▁ needed ▁ for ▁ " + " Palindrome ▁ Partitioning ▁ is ▁ " + minPalPartion ( str ) ) ; } }

Index/key variables: i, j, k, n
Accumulator variables: L, i, k
Iterator variables: L, i, k
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static class Node { int data ; Node left , right ; } static class INT { int v ; INT ( int a ) { v = a ; } } static Node getNode ( int data ) { Node newNode = new Node ( ) ; newNode . data = data ; newNode . left = newNode . right = null ; return newNode ; } static int countSubtreesWithSumX ( Node root , INT count , int x ) { if ( root == null ) return 0 ; int ls = countSubtreesWithSumX ( root . left , count , x ) ; int rs = countSubtreesWithSumX ( root . right , count , x ) ; int sum = ls + rs + root . data ; if ( sum == x ) count . v ++ ; return sum ; } static int countSubtreesWithSumXUtil ( Node root , int x ) { if ( root == null ) return 0 ; INT count = new INT ( 0 ) ; int ls = countSubtreesWithSumX ( root . left , count , x ) ; int rs = countSubtreesWithSumX ( root . right , count , x ) ; if ( ( ls + rs + root . data ) == x ) count . v ++ ; return count . v ; } public static void main ( String args [ ] ) { Node root = getNode ( 5 ) ; root . left = getNode ( - 10 ) ; root . right = getNode ( 3 ) ; root . left . left = getNode ( 9 ) ; root . left . right = getNode ( 8 ) ; root . right . left = getNode ( - 4 ) ; root . right . right = getNode ( 7 ) ; int x = 7 ; System . out . println ( " Count ▁ = ▁ " + countSubtreesWithSumXUtil ( root , x ) ) ; } }

Accumulator variables: v
Class/struct names: GFG, INT, Node
Java program:
import java . util . * ; class GFG { static void minchanges ( int [ ] [ ] mat ) { int N = mat . length ; int M = mat [ 0 ] . length ; int i , j , ans = 0 , x ; HashMap < Integer , Integer > mp = new HashMap < Integer , Integer > ( ) ; for ( i = 0 ; i < N / 2 ; i ++ ) { for ( j = 0 ; j < M / 2 ; j ++ ) { if ( mp . containsKey ( mat [ i ] [ M - 1 - j ] ) ) { mp . put ( mat [ i ] [ M - 1 - j ] , mp . get ( mat [ i ] [ M - 1 - j ] ) + 1 ) ; } else { mp . put ( mat [ i ] [ M - 1 - j ] , 1 ) ; } if ( mp . containsKey ( mat [ i ] [ j ] ) ) { mp . put ( mat [ i ] [ j ] , mp . get ( mat [ i ] [ j ] ) + 1 ) ; } else { mp . put ( mat [ i ] [ j ] , 1 ) ; } if ( mp . containsKey ( mat [ N - 1 - i ] [ M - 1 - j ] ) ) { mp . put ( mat [ N - 1 - i ] [ M - 1 - j ] , mp . get ( mat [ N - 1 - i ] [ M - 1 - j ] ) + 1 ) ; } else { mp . put ( mat [ N - 1 - i ] [ M - 1 - j ] , 1 ) ; } if ( mp . containsKey ( mat [ N - 1 - i ] [ j ] ) ) { mp . put ( mat [ N - 1 - i ] [ j ] , mp . get ( mat [ N - 1 - i ] [ j ] ) + 1 ) ; } else { mp . put ( mat [ N - 1 - i ] [ j ] , 1 ) ; } x = 0 ; for ( Map . Entry < Integer , Integer > it : mp . entrySet ( ) ) { x = Math . max ( x , it . getValue ( ) ) ; } ans = ans + 4 - x ; mp . clear ( ) ; } } if ( N % 2 == 1 ) { for ( i = 0 ; i < M / 2 ; i ++ ) { if ( mat [ N / 2 ] [ i ] != mat [ N / 2 ] [ M - 1 - i ] ) ans ++ ; } } if ( M % 2 == 1 ) { for ( i = 0 ; i < N / 2 ; i ++ ) { if ( mat [ i ] [ M / 2 ] != mat [ N - 1 - i ] [ M / 2 ] ) ans ++ ; } } System . out . print ( ans ) ; } public static void main ( String [ ] args ) { int [ ] [ ] mat = { { 1 , 2 , 3 } , { 4 , 5 , 3 } , { 1 , 2 , 1 } } ; minchanges ( mat ) ; } }

Index/key variables: i, j
Accumulator variables: ans, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static void checkprefix ( int A , int B ) { String s1 = String . valueOf ( A ) ; String s2 = String . valueOf ( B ) ; boolean result ; result = s1 . startsWith ( s2 ) ; if ( result ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } } public static void main ( String [ ] args ) { int A = 12345 , B = 12 ; checkprefix ( A , B ) ; } }

Class/struct names: GFG
Java program:
import java . util . regex . * ; class GFG { public static boolean isIdentical ( String str ) { String regex = " \\ b ( [ a - zA - Z0-9 ] ) \\ 1 \\ 1 + \\ b " ; Pattern p = Pattern . compile ( regex ) ; if ( str == null ) { return false ; } Matcher m = p . matcher ( str ) ; return m . matches ( ) ; } public static void main ( String args [ ] ) { String str1 = " aaa " ; System . out . println ( isIdentical ( str1 ) ) ; String str2 = "11111" ; System . out . println ( isIdentical ( str2 ) ) ; String str3 = " aaab " ; System . out . println ( isIdentical ( str3 ) ) ; String str4 = " abc " ; System . out . println ( isIdentical ( str4 ) ) ; String str5 = " aa " ; System . out . println ( isIdentical ( str5 ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . regex . * ; class GFG { public static boolean isValidMACAddress ( String str ) { String regex = " ^ ( [0-9A - Fa - f ] { 2 } [ : - ] ) " + " { 5 } ( [0-9A - Fa - f ] { 2 } ) | " + " ( [0-9a - fA - F ] { 4 } \\ . " + " [ 0-9a - fA - F ] { 4 } \\ . " + " [ 0-9a - fA - F ] { 4 } ) $ " ; Pattern p = Pattern . compile ( regex ) ; if ( str == null ) { return false ; } Matcher m = p . matcher ( str ) ; return m . matches ( ) ; } public static void main ( String args [ ] ) { String str1 = "01-23-45-67-89 - AB " ; System . out . println ( isValidMACAddress ( str1 ) ) ; String str2 = "01:23:45:67:89 : AB " ; System . out . println ( isValidMACAddress ( str2 ) ) ; String str3 = "0123.4567.89AB " ; System . out . println ( isValidMACAddress ( str3 ) ) ; String str4 = "01-23-45-67-89 - AH " ; System . out . println ( isValidMACAddress ( str4 ) ) ; String str5 = "01-23-45-67 - AH " ; System . out . println ( isValidMACAddress ( str5 ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . regex . * ; class GFG { public static boolean isValidGUID ( String str ) { String regex = " ^ [ { ] ? [ 0-9a - fA - F ] { 8 } " + " - ( [ 0-9a - fA - F ] { 4 } - ) " + " { 3 } [ 0-9a - fA - F ] { 12 } [ } ] ? $ " ; Pattern p = Pattern . compile ( regex ) ; if ( str == null ) { return false ; } Matcher m = p . matcher ( str ) ; return m . matches ( ) ; } public static void main ( String args [ ] ) { String str2 = "123e4567 - e89b - 12d3" + " - a456-9AC7CBDCEE52" ; System . out . println ( isValidGUID ( str2 ) ) ; String str3 = " { 123e4567 - e89b - 12d3 - " + " a456-9AC7CBDCEE52 } " ; System . out . println ( isValidGUID ( str3 ) ) ; String str1 = "123e4567 - h89b - 12d3 - a456" + " - 9AC7CBDCEE52" ; System . out . println ( isValidGUID ( str1 ) ) ; String str4 = "123e4567 - h89b - 12d3 - a456" ; System . out . println ( isValidGUID ( str4 ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . regex . * ; class GFG { public static boolean isValidLicenseNo ( String str ) { String regex = " ^ ( ( [ A - Z ] { 2 } [ 0-9 ] { 2 } ) " + " ( ▁ ) | ( [ A - Z ] { 2 } - [0-9 ] " + " { 2 } ) ) ( (19 ▁ 20 ) [ 0-9 ] " + " [ 0-9 ] ) [0-9 ] { 7 } $ " ; Pattern p = Pattern . compile ( regex ) ; if ( str == null ) { return false ; } Matcher m = p . matcher ( str ) ; return m . matches ( ) ; } public static void main ( String args [ ] ) { String str1 = " HR - 0619850034761" ; System . out . println ( isValidLicenseNo ( str1 ) ) ; String str2 = " UP14 ▁ 20160034761" ; System . out . println ( isValidLicenseNo ( str2 ) ) ; String str3 = "12HR - 37200602347" ; System . out . println ( isValidLicenseNo ( str3 ) ) ; String str4 = " MH27 ▁ 30123476102" ; System . out . println ( isValidLicenseNo ( str4 ) ) ; String str5 = " GJ - 2420180" ; System . out . println ( isValidLicenseNo ( str5 ) ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class Node { int data ; Node left ; Node right ; Node ( int data ) { this . data = data ; } } class GFG { static int count = 0 ; static Node ptr ; int countSubtreesWithSumXUtil ( Node root , int x ) { int l = 0 , r = 0 ; if ( root == null ) return 0 ; l += countSubtreesWithSumXUtil ( root . left , x ) ; r += countSubtreesWithSumXUtil ( root . right , x ) ; if ( l + r + root . data == x ) count ++ ; if ( ptr != root ) return l + root . data + r ; return count ; } public static void main ( String [ ] args ) { Node root = new Node ( 5 ) ; root . left = new Node ( - 10 ) ; root . right = new Node ( 3 ) ; root . left . left = new Node ( 9 ) ; root . left . right = new Node ( 8 ) ; root . right . left = new Node ( - 4 ) ; root . right . right = new Node ( 7 ) ; int x = 7 ; ptr = root ; System . out . println ( " Count ▁ = ▁ " + new GFG ( ) . countSubtreesWithSumXUtil ( root , x ) ) ; } }

Accumulator variables: count, l, r
Class/struct names: GFG, Node
Java program:
import java . util . regex . * ; class GFG { public static boolean isValidPassportNo ( String str ) { String regex = " ^ [ A - PR - WYa - pr - wy ] [1-9 ] \\ d " + " \\ s ? \\ d { 4 } [ 1-9 ] $ " ; Pattern p = Pattern . compile ( regex ) ; if ( str == null ) { return false ; } Matcher m = p . matcher ( str ) ; return m . matches ( ) ; } public static void main ( String args [ ] ) { String str1 = " A21 ▁ 90457" ; System . out . println ( isValidPassportNo ( str1 ) ) ; String str2 = " A0296457" ; System . out . println ( isValidPassportNo ( str2 ) ) ; String str3 = " Q2096453" ; System . out . println ( isValidPassportNo ( str3 ) ) ; String str4 = "12096457" ; System . out . println ( isValidPassportNo ( str4 ) ) ; String str5 = " A209645704" ; System . out . println ( isValidPassportNo ( str5 ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . regex . * ; class GFG { public static boolean isValidVisaCardNo ( String str ) { String regex = " ^ 4[0-9 ] { 12 } ( ? : [0-9 ] { 3 } ) ? $ " ; Pattern p = Pattern . compile ( regex ) ; if ( str == null ) { return false ; } Matcher m = p . matcher ( str ) ; return m . matches ( ) ; } public static void main ( String args [ ] ) { String str1 = "4155279860457" ; System . out . println ( isValidVisaCardNo ( str1 ) ) ; String str2 = "4155279860457201" ; System . out . println ( isValidVisaCardNo ( str2 ) ) ; String str3 = "4155279" ; System . out . println ( isValidVisaCardNo ( str3 ) ) ; String str4 = "6155279860457" ; System . out . println ( isValidVisaCardNo ( str4 ) ) ; String str5 = "415a27 # # 60457" ; System . out . println ( isValidVisaCardNo ( str5 ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . regex . * ; class GFG { public static boolean isValidMasterCardNo ( String str ) { String regex = " ^ 5[1-5 ] [ 0-9 ] { 14 } | " + " ^ ( 222[1-9 ] ▁ 22[3-9 ] \\ d ▁ " + "2[3-6 ] \\ d { 2 } ▁ 27[0-1 ] \\ d ▁ " + "2720 ) [ 0-9 ] { 12 } $ " ; Pattern p = Pattern . compile ( regex ) ; if ( str == null ) { return false ; } Matcher m = p . matcher ( str ) ; return m . matches ( ) ; } public static void main ( String args [ ] ) { String str1 = "5114496353984312" ; System . out . println ( isValidMasterCardNo ( str1 ) ) ; String str2 = "2720822463109651" ; System . out . println ( isValidMasterCardNo ( str2 ) ) ; String str3 = "5582822410" ; System . out . println ( isValidMasterCardNo ( str3 ) ) ; String str4 = "6082822463100051" ; System . out . println ( isValidMasterCardNo ( str4 ) ) ; String str5 = "2221149a635 # # 843" ; System . out . println ( isValidMasterCardNo ( str5 ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . regex . * ; class GFG { public static boolean isValidCVVNumber ( String str ) { String regex = " ^ [ 0-9 ] { 3,4 } $ " ; Pattern p = Pattern . compile ( regex ) ; if ( str == null ) { return false ; } Matcher m = p . matcher ( str ) ; return m . matches ( ) ; } public static void main ( String args [ ] ) { String str1 = "561" ; System . out . println ( isValidCVVNumber ( str1 ) ) ; String str2 = "5061" ; System . out . println ( isValidCVVNumber ( str2 ) ) ; String str3 = "50614" ; System . out . println ( isValidCVVNumber ( str3 ) ) ; String str4 = "5a # 1" ; System . out . println ( isValidCVVNumber ( str4 ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . regex . * ; class GFG { public static boolean isValidIFSCode ( String str ) { String regex = " ^ [ A - Z ] { 4 } 0 [ A - Z0-9 ] { 6 } $ " ; Pattern p = Pattern . compile ( regex ) ; if ( str == null ) { return false ; } Matcher m = p . matcher ( str ) ; return m . matches ( ) ; } public static void main ( String args [ ] ) { String str1 = " SBIN0125620" ; System . out . println ( isValidIFSCode ( str1 ) ) ; String str2 = " SBIN0125" ; System . out . println ( isValidIFSCode ( str2 ) ) ; String str3 = "1234SBIN012" ; System . out . println ( isValidIFSCode ( str3 ) ) ; String str4 = " SBIN7125620" ; System . out . println ( isValidIFSCode ( str4 ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . regex . * ; class GFG { public static boolean isValidGSTNo ( String str ) { String regex = " ^ [ 0-9 ] { 2 } [ A - Z ] { 5 } [ 0-9 ] { 4 } " + " [ A - Z ] { 1 } [ 1-9A - Z ] { 1 } " + " Z [ 0-9A - Z ] { 1 } $ " ; Pattern p = Pattern . compile ( regex ) ; if ( str == null ) { return false ; } Matcher m = p . matcher ( str ) ; return m . matches ( ) ; } public static void main ( String args [ ] ) { String str1 = "06BZAHM6385P6Z2" ; System . out . println ( isValidGSTNo ( str1 ) ) ; String str2 = "06BZAF67" ; System . out . println ( isValidGSTNo ( str2 ) ) ; String str3 = " AZBZAHM6385P6Z2" ; System . out . println ( isValidGSTNo ( str3 ) ) ; String str4 = "06BZ63AHM85P6Z2" ; System . out . println ( isValidGSTNo ( str4 ) ) ; String str5 = "06BZAHM6385P6F2" ; System . out . println ( isValidGSTNo ( str5 ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . regex . * ; class GFG { public static boolean isValidHTMLTag ( String str ) { String regex = " < ( \" [ ^ \" ] * \" ▁ ' [ ^ ' ] * ' ▁ [ ^ ' \" > ] ) * > " ; Pattern p = Pattern . compile ( regex ) ; if ( str == null ) { return false ; } Matcher m = p . matcher ( str ) ; return m . matches ( ) ; } public static void main ( String args [ ] ) { String str1 = " < input ▁ value ▁ = ▁ ' > ' > " ; System . out . println ( isValidHTMLTag ( str1 ) ) ; String str2 = " < br / > " ; System . out . println ( isValidHTMLTag ( str2 ) ) ; String str3 = " br / > " ; System . out . println ( isValidHTMLTag ( str3 ) ) ; String str4 = " < ' br / > " ; System . out . println ( isValidHTMLTag ( str4 ) ) ; String str5 = " < input ▁ value ▁ = > ▁ > " ; System . out . println ( isValidHTMLTag ( str5 ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . regex . * ; class GFG { public static boolean isValidDomain ( String str ) { String regex = " ^ ( ( ? ! - ) [ A - Za - z0-9 - ] " + " { 1,63 } ( ? < ! - ) \\ . ) " + " + [ A - Za - z ] { 2,6 } " ; Pattern p = Pattern . compile ( regex ) ; if ( str == null ) { return false ; } Matcher m = p . matcher ( str ) ; return m . matches ( ) ; } public static void main ( String args [ ] ) { String str1 = " geeksforgeeks . org " ; System . out . println ( isValidDomain ( str1 ) ) ; String str2 = " contribute . geeksforgeeks . org " ; System . out . println ( isValidDomain ( str2 ) ) ; String str3 = " - geeksforgeeks . org " ; System . out . println ( isValidDomain ( str3 ) ) ; String str4 = " geeksforgeeks . o " ; System . out . println ( isValidDomain ( str4 ) ) ; String str5 = " . org " ; System . out . println ( isValidDomain ( str5 ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . regex . * ; class GFG { public static boolean isValidSSN ( String str ) { String regex = " ^ ( ? ! 666 ▁ 000 ▁ 9 \\ d { 2 } ) \\ d { 3 } " + " - ( ? !00 ) \\ d { 2 } - " + " ( ? ! 0 { 4 } ) \\ d { 4 } $ " ; Pattern p = Pattern . compile ( regex ) ; if ( str == null ) { return false ; } Matcher m = p . matcher ( str ) ; return m . matches ( ) ; } public static void main ( String args [ ] ) { String str1 = "856-45-6789" ; ; System . out . println ( isValidSSN ( str1 ) ) ; String str2 = "000-45-6789" ; ; System . out . println ( isValidSSN ( str2 ) ) ; String str3 = "856-452-6789" ; System . out . println ( isValidSSN ( str3 ) ) ; String str4 = "856-45-0000" ; System . out . println ( isValidSSN ( str4 ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . regex . * ; class GFG { public static boolean imageFile ( String str ) { String regex = " ( [ ^ \\ s ] + ( \\ . ( ? i ) ( jpe ? g ▁ png ▁ gif ▁ bmp ) ) $ ) " ; Pattern p = Pattern . compile ( regex ) ; if ( str == null ) { return false ; } Matcher m = p . matcher ( str ) ; return m . matches ( ) ; } public static void main ( String args [ ] ) { String str1 = " abc . png " ; System . out . println ( imageFile ( str1 ) ) ; String str2 = " im . jpg " ; System . out . println ( imageFile ( str2 ) ) ; String str3 = " . gif " ; System . out . println ( imageFile ( str3 ) ) ; String str4 = " abc . mp3" ; System . out . println ( imageFile ( str4 ) ) ; String str5 = " ▁ . jpg " ; System . out . println ( imageFile ( str5 ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . regex . * ; class GFG { public static boolean isValidAadharNumber ( String str ) { String regex = " ^ [ 2-9 ] { 1 } [ 0-9 ] { 3 } \\ s [ 0-9 ] { 4 } \\ s [ 0-9 ] { 4 } $ " ; Pattern p = Pattern . compile ( regex ) ; if ( str == null ) { return false ; } Matcher m = p . matcher ( str ) ; return m . matches ( ) ; } public static void main ( String args [ ] ) { String str1 = "3675 ▁ 9834 ▁ 6015" ; System . out . println ( isValidAadharNumber ( str1 ) ) ; String str2 = "4675 ▁ 9834 ▁ 6012 ▁ 8" ; System . out . println ( isValidAadharNumber ( str2 ) ) ; String str3 = "0175 ▁ 9834 ▁ 6012" ; System . out . println ( isValidAadharNumber ( str3 ) ) ; String str4 = "3675 ▁ 98AF ▁ 60#2" ; System . out . println ( isValidAadharNumber ( str4 ) ) ; String str5 = "417598346012" ; System . out . println ( isValidAadharNumber ( str5 ) ) ; } }

Class/struct names: GFG