Melee is the best 1on1 build because it has the best damage output but you need to be close enough. If you're up against an experienced melee who knows there is a lone noob around, of course you're gonna have a tough time.
The best way to kill a melee is to be able to shoot him from as much distance as possible, preferable with a torsospam weapon, especially if it has knockback perks like desert eagle or remington. Another way to counter Ripper melees, which are most prominent recently, is to have a super sledge or mega power fist handy.
If you know there is a melee in some building, then never go in and try to fight him toe to toe, unless youre specifically set up to counter it. With more of a SG sniper build, you could try to use 14mm pistol and groin shots, though I have never tried that myself. Other weapons that might be worth a try are the pulse pistol, if you have an agressive build yourself and you make the melee bridge 15-20hex to you first, then it might have enough damage to win the fight.
Generally though, melees are great in small fights but very situational and more difficult to play in bigger teamfights where you can't easily force people into 1on1 standoffs.
Now, if you're talking about the melee sneak hitting you in the back for 250, then it's a bit different. Sneaks with just a leatherjacket die very very quickly to deagle torsospam (though they die to pretty much anything very quickly). if you have a feeling there is a sneak around, remember that he has to come from your back to get his silent death damage bonus. If he doesnt hit you in the back, he wont deal enough damage to offtset the huge difference in armor and with quick reactions and a weapon that's not a grenade launcher or something, you should be able to kill him before he gets more attacks.
A burst weapon is also handy here to try to hexburst in the direction of the sneak to desneak him early. A good strategy against melee sneaks also is to run into the next corner and keep your back against the wall, this way there is no way for him to get silent death damage bonus.