According to social networking site LinkedIn, Celestine Omin, 28, landed at New York’s JFK airport last Sunday after a 24-hour flight from Nigeria.
Mr Omin is employed by Andela, a tech start-up with offices in New York, Lagos, Nairobi and San Francisco.
The firm says it recruits “the most talented developers on the African continent” and connects them with tech employers in the US for potential job vacancies. Facebook chief, Mark Zuckerberg, visited Andela’s office in Lagos last year.
Mr Omin had reportedly been granted a short-term visa to work with First Access, a financial technology company in New York’s Manhattan district.
After being asked a series of questions by a US Customs and Border Protection officer, he was taken into a room for further checks.
“Your visa says you are a software engineer. Is that correct?” an officer was reported to have asked Mr Omin.
He said he was then given a piece of paper and a pen and told to answer these two questions to prove he is actually a software engineer: “Write a function to check if a Binary Search Tree is balanced.”
“What is an abstract class, and why do you need it?”
Mr Omin told LinkedIn it seemed to him the questions had been “Googled” by “someone with no technical background”.
He said later on Twitter that he was “too tired to even think”, and told the officer they could “talk about other computer science concepts”.
After he handed back his answers, he was told by the officer that they were wrong. He said he presumed he was required to provide “the Wikipedia definition” for the questions.
However, he was even more surprised a little later when the officer told him he was “free to go”.
“Look, I am going to let you go, but you don’t look convincing to me,” said the officer, according to Mr Omin.
“I didn’t say anything back. I just walked out.”
He later found out that border protection officers had phoned Andela to verify his story.
The BBC approached the Customs and Border Protection department for a comment but was yet to receive a reply.
Nigeria is not one of the seven countries included in US President Donald Trump’s temporary immigration pause.
However, the African country has been struggling with the threat of terrorism in recent times, in particular from the militant Islamist group Boko Haram.
Mr Trump has repeatedly called for “strong borders” and “extreme vetting” since taking office on 20 January. (ThisDay)