Silicon Valley’s top-tier tech companies are like a powerful magnet, attracting many of the best and brightest millennials who desperately want to work there. But for every coveted job, there are far more applicants than can ever be hired.

If you want to get through the door at one of these notoriously exclusive companies, you want to talk to someone like Gayle Laakmann McDowell. She worked as a software engineer at Apple, Microsoft and Google, where she sat on the corporate hiring committee—and was once at the top 1 percent in terms of interviews conducted at the tech giant. McDowell has also worked with Amazon, Facebook, Uber and Yahoo to help them attract and retain top talent.

McDowell, who has a bachelor’s and master’s degree in computer science from the University of Pennsylvania and an MBA from Wharton, is also the author of three tech books, including Cracking the Coding Interview, which is the No. 1 selling book in three Amazon categories: software development, job hunting and interviewing.

When the Observer spoke to McDowell, her advice struck us as bigger than just getting past the gatekeepers at top tech companies—it’s filled with key lessons for how to be successful in business and in life.

Here’s everything you need to know, as told by McDowell to the Observer:

Before the Interview

Understand the culture. It sounds funny but Silicon Valley’s top tech companies tend to shun the business side of their operations. Engineers see themselves as working for engineering shops not stuffy businesses. What drives engineers is their love of engineering and building really cool stuff for customers—not enhancing the bottom line.

It’s not all about the degree. There’s this mistaken idea that you need a computer science degree to get a job at one of Silicon Valley’s top tech companies. But that’s really not the case at all. The biggest hurdle that candidates without a computer science degree face isn’t a lack of knowledge, it’s an insecurity that they’re missing that “secret sauce” during the interview process. As soon as I ask a question that seems “academic,” they say they can’t do it even though they absolutely have the knowledge and skills to tackle it. What they fail to realize is that the problems are designed to be difficult for everyone.

Recognize the technical bias. Tech companies have a huge bias toward candidates with technical skill, even if you’re not applying for a job as a coder. If you want to work at a tech company, in virtually any role, you need to demonstrate a passion for technology. Anyone can spend a weekend online learning the basics of how to write really simple code. No, you won’t build an iPhone app in a weekend. But you can learn enough of the basics to get a decent understanding of what the software development process is all about. Trust me: It’s not as scary as you think.

Build something on your own. If you’re already working at Google and you want to move to Facebook, you probably won’t have a problem making the jump. But what if you’re a coder at an insurance company in the Midwest? If you send your resume to Google, you’re not likely to stand out. So what can you do? One excellent strategy is to start a project—any project—on your own. The details are less important than the fact that you’re taking ownership of something and showing initiative and drive. So start a small business. Build an app of your own. Do whatever it takes to demonstrate your entrepreneurial mindset. You’ll also develop new skills in the process, and it can make a huge difference in how you’re perceived.

Don’t get married to one skill. Whatever your role may be, don’t be married to just one skill, one technique, or one way of seeing the world. If you’re a programmer, that means not being totally attached to a single language. Sometimes, when people interview, they can clearly be very smart—but incredibly attached to one programming language. When it becomes clear that they don’t want to work with anything else, that’s worrisome. The fact that the candidate hasn’t felt the need to learn more skills is worrisome. Needs change, projects change, teams change. Tech companies value open-mindedness and flexibility. Even if you are particularly passionate about one thing, stay open to moving new directions.

Nine-to-5 isn’t enough. At top tech companies, extracurricular work isn’t a differentiating factor— it’s the expectation. Even if you don’t have time to build something fully on your own, as recommended above, you need to keep tinkering on the side. I once worked with a candidate at Google for a product manager role. During the interview, he started talking about how he kept chickens at his house. He was extremely passionate about building a door for the coop that opened and closed automatically to control the chickens’ movements. It sounds silly, and it had nothing to do with his 9-to-5 job description, but it demonstrated his passion for applying technical solutions to real-world problems.

Practice, Practice, Practice. Regardless of the role you’re applying for, top tech companies will assess your capacity through problem-solving tests. Your performance will improve with practice—so it’s essential that you do so. Companies are so aware of the importance of practice that they now send preparatory material to candidates directly. (Google recruiters refer candidates to my books and Facebook has hired me to teach an interview prep class for their candidates.) You can be sure of this: Your competition is practicing.

During the Interview

Dress to blend. If you walk into a tech company wearing a suit and tie, you’re going to look out of place and signal that you don’t understand their culture. You’ll look like one of those stuffy business folks. At tech companies, the standard interview uniform is jeans and a nice top or shirt; on the job attire might be even more casual. I recall quite clearly one candidate walked into a job interview at Apple in a suit and tie. He was extremely smart, had an MBA from Wharton, and he quickly realized he was overdressed. As the interview progressed, he started loosening his tie, then took it off entirely, and finally threw his jacket over the back of a chair. He got the job.

Your interview will be challenging: Get used to it. Understand that the purpose of an interview with a tech company is to assess your skills in real-time. An interview at Google, Facebook, Amazon, and Apple is not just a chat about your past achievements. This is true of interviews for every role. If you’re a coder, it means you’d better know your core computer science concepts—and practice answering challenging questions about them. If you’re applying for a product management role, it means you need to be ready to demonstrate your product design and quantitative skills on the fly. If you’re in marketing, you can count on having marketing problems thrown at you.

Don’t. Give. Up. Ever. Often times people get a problem that they don’t think they know the answer to immediately and then they just quit on themselves. Here’s what they don’t realize: The interviewer assumes that you don’t know the answer to the question. What they’re testing is your ability—and your willingness—to tackle problems that seem completely baffling. They are looking for you to keep working toward a better and better answer. If you’re ever about to give up remember this: The interview process is designed to challenge you, and even the best candidates feel “stumped.” The question is this: What do you do next?

One Google candidate asked his lunch interviewers where all the “hot chicks” were…. Needless to say, the candidate didn’t get an offer.

Show initiative even at the risk of failure. No matter where you’re interviewing, you want to convey a sense of initiative. Even teams at the biggest tech companies tend to believe that they operate like a startup. They value moving—and even failing—fast. At tech companies, the ethos is that it’s better to try and fail than not to try at all. I once interviewed a candidate for Amazon who hid what I thought was the best part of her resume. She’d started a gaming company that had to close its doors within six months. She didn’t bring it up because she saw it as a failure. But, in our minds, starting a company in the first place was a huge win for her.

Never be lazy. There’s a category of candidate I describe as “mentally lazy.” They may be very smart, but as soon as they get a tough problem—one where the best answer doesn’t jump out at them—they either give up or ask for help. That’s a big red flag. One candidate I interviewed at Facebook was absolutely brilliant—but only when I forced him to be. Guess what? Tech companies know that in the real world, you won’t have an interviewer forcing you to give your all. It doesn’t matter that you can tackle tough problems if, ultimately, you won’t. (Nope, he didn’t get the job.)

Don’t say something stupid and screw it all up. Tech companies go to great lengths not to come across as “corporate.” Because of that, candidates can sometimes get overly chummy during the interview process during, say, an informal lunch. One Google candidate asked his lunch interviewers where all the “hot chicks” were. Lunch interviewers don’t generally submit candidate feedback but this one made an exception. Needless to say, the candidate didn’t get an offer. Tech companies aren’t stuffy—but the office isn’t a frat party.

After the Interview

Life is a team sport. And so is software development. I clearly remember one candidate at LinkedIn who was a brilliant developer—as long as he worked alone. But he got incredibly defensive with his teammates whenever anyone offered even a benign suggestion. It had a serious impact on his career. Another candidate, who I worked with during the interview process at Google, would dismiss all of my feedback with a quick “yep-yep-yep”—including, ironically, my feedback to him that he came off as dismissive when he did that. Interviewers are always on the lookout for those kinds of red flags. Don’t be one of those people.

Stay up to date and commit to lifelong learning. There’s an expectation at top tech companies that you learn quickly and that you enjoy the learning process. When someone knows 10 different flavors of Java and nothing else, I wonder if they’ll be willing to learn the necessary skills for a new role. Technologies and approaches change rapidly and you need to be able to adapt at the same speed. There’s no better way to guard against professional obsolescence than to develop a passion for learning new things—even if it doesn’t directly relate to your job right now.

Always build your network. Whether you get a job offer or not, keep in touch with as many of the people that you met as possible. Even an interview that doesn’t result in an offer is still an opportunity to build your network. Tech companies are fueled by talent and knowing the right person is often the gateway to your next opportunity. The goal is to keep your network as broad as possible. Most people, including me, didn’t get referred by a friend but by a friend of a friend. Top tech companies are so starved for great talent that referrals don’t need to be close ones. Send a thank you note or a LinkedIn request to your recruiter and stay in touch.

It’s never over until you quit applying. Tech companies set a high bar and they understand that they often reject good people. Maybe you, or your interviewer, just had a bad day. Or maybe you need to develop your skills set a little further. Either way, it’s very common for a candidate to get rejected and then get an offer a year or two later. Never be afraid to reach out again. Your past “failure” won’t count against you.

How can I be so sure? I got rejected when I first applied to Google for an internship. The following year, when I applied for a full-time role, the recruiter expedited my interviews because I had done well, though not well enough, the last time around. When I did get hired, I went on to interview many more previously rejected candidates. I don’t care if the candidate got rejected in the past I only care about what they can do right now.