Hungary and Poland had a border in 1939 after the annexation by Hungary of Carpatho-Ukraine (the independent status of which was debatable in March 1939).
Hungary didn't acquire a border with Nazi Germany until the German annexation of Austria in 1938.
Hungary also bordered Slovakia in 1939-45 and Croatia 1941-45.
'Germany' is taken as referring only to Nazi Germany, not to the pre-1918 Empire while 'Yugoslavia' answers several different sets of borders and regimes there - royal Yugoslavia, socialist federal Yugoslavia, and Serbian-dominated nationalist 'Yugoslavia' after 1992.
Hungary as such didn't border some of these either e.g. Switzerland bordered the Austrian half of the empire.
Hungary didn't acquire a border with Nazi Germany until the German annexation of Austria in 1938.
Hungary also bordered Slovakia in 1939-45 and Croatia 1941-45.
'Germany' is taken as referring only to Nazi Germany, not to the pre-1918 Empire while 'Yugoslavia' answers several different sets of borders and regimes there - royal Yugoslavia, socialist federal Yugoslavia, and Serbian-dominated nationalist 'Yugoslavia' after 1992.
Hungary as such didn't border some of these either e.g. Switzerland bordered the Austrian half of the empire.