A double coset problem for classical groups