Image copyright Mathias Mikkelsen Image caption Mathias spent 12 weeks living in this cupboard

The BBC's weekly The Boss series profiles different business leaders from around the world. This week we speak to Mathias Mikkelsen, founder of Norwegian tech company Memory.

Mathias Mikkelsen was so keen to get his business up and running that he slept in a cupboard for three months.

Back in late 2013, the then 23-year-old entrepreneur had moved on his own from Norway to Silicon Valley in California, to try to secure backing for his start-up idea - an online project and time management tool called Timely.

There was just one big problem for the Norwegian - he didn't know a single person in the wider San Francisco Bay Area.

"At the time there wasn't really a tech start-up scene in Norway, so I decided that moving to Silicon Valley - the tech capital of the world - would be the best thing for me to do," says Mathias.

"But I didn't know anyone at all out there. So when I landed human instinct kicked in, and the first thing I knew I needed to do was make friends. Then I realised that most people make friends via work or at college, and I wasn't going to be joining a workplace or going to be a student."

Image copyright Mathias Mikkelsen Image caption After three months in a cupboard, Mathias was able to get a bunk bed after one person left the hacker house

So faced with the prospect of getting very lonely very quickly, Mathias devised a cunning plan.

"I decided that I would hire rooms in shared Airbnb houses, and move somewhere new every week," he says. "That way, law of averages, I would start to make friends."

Thankfully for Mathias his idea worked, and over the following months he slowly built up a circle of mates. But his next challenge - the holy grail - was to get himself into a "hacker house".

A hacker house is a property shared by a number of similar young tech entrepreneurs, who are all trying to get their business proposals off the ground. The idea is that everyone can help each other and share advice, inspiration and contacts.

In mid-2014 he was finally able to get himself into such a property in Silicon Valley, but there was a catch - all 15 of the proper beds were taken. So if he wanted in, he would have to sleep on an airbed in a windowless cupboard.

Mathias, now 29, says he jumped at the chance. "I slept in that cupboard for three months. Did I feel stupid or embarrassed? Not at all.

"Being in the hacker house was invaluable. It pushed me so much as an entrepreneur. It was extremely valuable and without it I don't think I would be where I am today."

Image copyright Memory Image caption Mathias' company - Memory - now employs 45 people

Fast forward to the present day, and Mathias' Timely app is now used by more than 5,000 companies across 160 countries.

Born in the far north of Norway, Mathias was raised in a town just outside the capital Oslo.

As a child he says that his initial dream was to become a professional football player, specifically for the English team Manchester United, but then as a teenager he discovered that he was much better at computer programming.

While still at secondary school he started to get paid to design websites for companies on a freelance basis. Mathias says his parents were initially not happy about this, "until I got my first paycheque".

More The Boss features:

Leaving school at 18, he then worked for a number of digital design companies in Oslo, where his work including making the in-flight entertainment system for airline Norwegian Air, and a Facebook campaign for charity Unicef.

But wanting to be his own boss, and wishing to develop his own business idea, he started work on Timely. Mathias launched its first iteration in May 2013 while still living in Oslo, but "nothing happened".

"I got some likes on Facebook, and some thumbs up from friends, but no real customers signing up," he says. "It went completely to hell. I'd put my all into it, night after night, then it launched and all I could hear was the sound of crickets. It was devastating, it takes the breath out of you."

Image copyright Getty Images Image caption In 2015 he moved the business back to Oslo

With his savings running low, Mathias says he realised he "only had one more shot" at making Timely a success. So it was time to place a big bet - he sold his apartment in Oslo to raise more funds, and moved to Silicon Valley.

After his time in the hacker house, and working with a fellow programmer in India, Mathias launched the second iteration of Timely at the end of 2014. Sales to businesses - who pay a subscription then slowly started to grow.

A year later, Mathias decided to move the business - which he called Memory - back to Oslo. "While there was no tech start-up scene in the city when I left, it has subsequently boomed. Oslo is now a great place to find tech staff."

Backed by $6m (£4.6m) of funding from investment firms in the US, UK and Norway, Memory now employs 45 people, and has annual sales of more than $2m.

Image copyright Inger Uppman Image caption Mathias has secured $6m of external investment for his business

Entrepreneurs like Mathias "tend to have certain innate characteristics when compared with the general population", says Brian Morgan, professor of entrepreneur at Cardiff Metropolitan University.

"This means that they are more likely to take risks and grasp opportunities.

"In the early years of product development it's always about resilience - the ability to keep going when the outlook looks bleak - and also self-reliance - the capacity to be resourceful and confident enough to depend only on yourself.

"Renting a cupboard in Silicon Valley to help get a start-up business to first base would seem to me to be a perfect example of the persistence and passion needed to become a successful entrepreneur."

Looking back on his three months living in a cupboard, Mathias says it was "a crazy time, but super cool". He adds: "I was working every minute of every day, so I honestly didn't care where I was sleeping."