A Nigerian software engineer claims he was detained by US immigration officials at New York's JFK Airport and given a written test on binary search trees to prove his tech knowledge. According to LinkedIn, 28-year-old Celestine Omin from Lagos, Nigeria, arrived in the US last Sunday (26 February) for the first time after a 24-hour flight from his home country.

Omin is employed by Andela, a startup that connects tech talent from across Africa with companies in the US such as Microsoft and IBM and is backed by Mark Zuckerberg and Priscilla Chan's fund, the Chan Zuckerberg Initiative. Receiving over 50,000 applicants for its job placement services, the startup is very selective and accepts just 0.5%.

The startup has offices in San Francisco, New York, Nairobi and Lagos, which Facebook CEO Zuckerberg visited last year.

Omin was reportedly granted a short-term work visa to work with New York-based fin-tech company First Access.

After waiting in line for 20 minutes, Omin said a Customs and Border Protection officer asked him a series of questions about the job before taking him to a small room for further questioning.

"Your visa says you are a software engineer. Is that correct?" another customs officer reportedly asked him. Omin was then given a piece of paper and a pen and told to answer two questions to prove his occupation:

"Write a function to check if a Binary Search Tree is balanced."

"What is an abstract class, and why do you need it?"

JFK airport
A Nigerian software engineer said he was detained by US immigration officers at JFK airport and was given a written test to prove his computer knowledge Spencer Platt/Getty Images

Omin, who has over seven years of experience, told LinkedIn that it seemed like someone with no technical background had searched on Google, "Questions to ask a software engineer."

On Twitter, Omin later said he was "too tired to even think" and was also asked about 10 computer science questions.

When he handed his answers after about 10 minutes, he was told that his answers were wrong.

"No one would tell me why I was being questioned," Omin told LinkedIn. "Every single time I asked [the official] why he was asking me these questions, he hushed me... I wasn't prepared for this. If I had known this was happening beforehand, I would have tried to prepare.

"That is when I thought I would never get into the United States."

The officer later told him he was "free to go", but did not offer much explanation.

"He said, 'Look, I am going to let you go, but you don't look convincing to me,'" Omin said. "I didn't say anything back. I just walked out." He later found out that Andela and First Access were contacted by US Customs to corroborate his story.

A US Customs and Border Protection spokesperson told LinkedIn that the agency "does not administer written tests to verify a traveller's purpose of travel", but did not comment on Omin's case. He noted that visitors entering the US "bear the burden of proof to establish that they are clearly eligible" and "must overcome all grounds of inadmissibility".

Nigeria is not one of the seven predominantly Muslim countries included in President Donald Trump's immigration order that temporarily restricts visitors.