Generate a string consisting of characters ' a ' and ' b ' that satisfy the given conditions | Function to generate and print the required string ; More ' b ' , append " bba " ; More ' a ' , append " aab " ; Equal number of ' a ' and ' b ' append " ab " ; Driver code
< ? php function generateString ( $ A , $ B ) { $ rt = " " ; while ( 0 < $ A 0 < $ B ) { if ( $ A < $ B ) { if ( 0 < $ B -- ) { $ rt . = ( ' b ' ) ; } if ( 0 < $ B -- ) { $ rt . = ( ' b ' ) ; } if ( 0 < $ A -- ) { $ rt . = ( ' a ' ) ; } } else if ( $ B < $ A ) { if ( 0 < $ A -- ) { $ rt . = ( ' a ' ) ; } if ( 0 < $ A -- ) { $ rt . = ( ' a ' ) ; } if ( 0 < $ B -- ) { $ rt . = ( ' b ' ) ; } } else { if ( 0 < $ A -- ) { $ rt . = ( ' a ' ) ; } if ( 0 < $ B -- ) { $ rt . = ( ' b ' ) ; } } } echo ( $ rt ) ; } $ A = 2 ; $ B = 6 ; generateString ( $ A , $ B ) ; ? >