Assuming the trains are travelling towards each other, to get the time they pass each other in, we have to add their speeds

speed of trains 1 = length of train/3 sec

speed of train 2 = length of train/4 sec

add the speed, we get

l/4 + l/3 = 7l/12

therefore the time taken will be 12/7 secs which is 1.7143 seconds(rounded off)