Are you expected to write perfect code on your first attempt in tech interviews?

Are you expected to write perfect code on your first attempt in tech interviews? by Istvan Jonyer

Answer by Istvan Jonyer:

As someone who interviewed many engineers at Google, I can tell you my approach. Others may do it differently, but Google trains everyone to interview properly.

When I ask you to write code on the whiteboard, what I am most curious about is your thought process. Therefore I vastly prefer people trying to 1) understand the problem well, and 2) develop an algorithm using drawings and examples, paying particular attention to edge cases. Only when we talked through all that, and both agree on the algorithm, should a candidate start to actually write code. At that point I always ask what their favorite language is, and ask them to use it. If they make a syntax error, I usually ask about it, but I don't really care about the error itself. What I care more about is how the candidate handles being corrected. Are they defensive? Insecure? Or confident and collaborative? The most important thing, of course, is whether the code reflects the algorithm they / we developed.

 If you launch into writing your code, as opposed to developing the algorithm using examples, you are likely to make mistakes. You are skipping an important step — the algorithm development. Writing code while at the same time thinking through the algorithm in your head is unnecessarily difficult in a high-pressure interview process.

The worst is when a candidate, upon hearing the question, turns to the whiteboard and presents a flawless algorithm, writing it out sequentially. I know that the person had heard the question before, and I learned nothing about their abilities. My notes in that case are literally "Invalid question, knew the answer".

If I sense that the candidate is not confident in their answer, I may even throw in a "mistake" to see if they're confident enough to disagree with me. This could also happen by an honest mistake on the part of the interviewer, which should not throw you off track, and you should stand up to your answer if you know you're right (and prove it).

To answer your question more directly, yes missing edge cases is a biggie. It means your process was wrong, you probably didn't try to develop the algorithm using examples, and you didn't take special care to identify and handle edge cases. If you've been a software engineer for a while, you know how many bugs are the result of missed edge cases, and how important they are.

Bottom line, you need to impress me, not hope to get away with mistakes.

Are you expected to write perfect code on your first attempt in tech interviews?

I am willing to sacrifice all of my free time to learn algorithms and prepare the Google interview in 1 year, how should I start?

I am willing to sacrifice all of my free time to learn algorithms and prepare the Google interview … by @jessicatysu

Answer by Jessica Su:

For learning algorithms, I recommend getting a copy of CLRS and reading

  • Chapter 2: Insertion sort and an introduction to the design and analysis of algorithms
  • Chapter 3: Big-O notation (you can’t neglect theory!)
  • Chapter 4: Recurrence relations and the master theorem
  • Chapter 5: Randomized algorithms
  • Chapter 6: Heaps
  • Chapter 7: Quicksort
  • Chapter 8: Lower bounds on comparison sort, and linear-time sorting algorithms
  • Chapter 9: The median-of-medians algorithm
  • Chapter 10: Linked lists, stacks, and queues
  • Chapter 11: Hash tables and why they are not always O(1) time
  • Chapter 12: Binary search trees
  • Chapter 13: Red-black trees (you should know that they exist)
  • Chapters 15–16: Dynamic programming and greedy algorithms
  • Chapter 17: Amortized analysis
  • Chapters 22–26: Graph algorithms — VERY IMPORTANT, especially Chapter 22 on breadth-first search and depth-first search.

Since you have an entire year to study, it should be no trouble to read all these chapters, and do all of the exercises in the book. I guarantee you that at that point, you will have a masterful command of what is typically covered in an introductory algorithms class.

It is also essential that you practice implementing algorithms. For that, I suggest working on a large software project, and gaining substantial experience in either C++, Java, or Python. You can also practice toy algorithms problems on online judges such as LeetCode or HackerRank.

I am willing to sacrifice all of my free time to learn algorithms and prepare the Google interview in 1 year, how should I start?

What’s the best way to get smarter?

What’s the best way to get smarter? by Timofey Yuriev

Answer by Timofey Yuriev:

Get very hungry. Hunger elevates your HGH, HGH restores your body functions. After 2 days your brain switches to the best possible source of energy for it: ketones. Your body can exist for extremely long times without food, vitamins, supplements and all other crap that marketing placed in our heads.

Plato and Socrates fasted for 7-10 days to gain physical and mental efficiency. Pythagoras fasted 40 days before his examination at Alexandria and required his students to fast before entering his classes.

During the Vietnam and WW2 wars, prisoners tell us stories of how sharp their mind was in the absence of food. Some could read entire books from their memories.

Some stories: Fasting for Brain Training and Unbroken by Laura Hillenbrand.

In this book, the main character describes a prisoner who would read entire books from memory, and another who learned the Norwegian language in a few weeks. Incredibly, these feats were so commonplace that prisoners simply accepted it as a fact of life that starvation increases cognitive ability.

Hunting state

When we get hungry our body switches into hunting state. Hormone levels rise, our mental abilities rise, our strenght, endurance and willpower goes thru the roof. Our mind becomes crystal clear. Our body switches to the internal resources and begins to consume fats stored everywhere. Muscles are saved as the last resort of energy. When I go thru 48 hrs of fasting, I feel the magnitude of power growing inside of me. At this state I feel like I can run forever and there is nothing in the world that can stop me.

In mammals, mental activity increases in hunger and decreases with satiation. We have all experienced this as “food coma”. Think about that large Thanksgiving turkey. After one big meal are we mentally sharp? Or dull as a brick? How about the opposite? Think about a time when you were really hungry. Were you tired and slothful? No – your senses were on hyper-alert and you were mentally sharp as a needle. The idea that food make you concentrate better is completely wrong.

Mental sharpness increases during fasting.

  1. Don't feed your head
  2. Calorie restriction and aging: review of the literature and implications for studies in humans
  3. Neuroscientist Shows What Fasting Does To Your Brain & Why Big Pharma Won’t Study It
  4. Fasting for Mental Health: Does it Work? – Mind the Science Gap
  5. Why Fast? Part Four – Brain Health | Mark's Daily Apple

My diet

I skip breakfast and lunch everyday. I usually begin feeding my body after about 4–5pm and I eat a lot. I keep my protein intake high. My diet is based on beans, egg whites, chicken, fish, rice, yum potatoes, cabbage. No sugar, no dairy (kefir is one exception), no meat. I'm doing it for the last 6 months and I feel better than ever before. Clear head, ton of energy. But I also train every day.

Your physical shape

Keep in mind, if you follow the regiment above, you will get very lean, very fast. If you would like to also look strong, then you will have to train every day or every other day. I exercise intensely for around 30–40 min every morning and now, after 3 months, I look like a ripped bodybuilder. Your body uses fat for energy and muscles are saved as a last resort.

In this “Hungry Hunter” state you've got your body pumped up with natural HGH, and HGH is what elite bodybuilders and life extension cliinics use. Shots of HGH cost them thousands of dollars each month and you are getting it for free. If you combine this state with some physical training, then expect amazing results in extremely short time.

More: Hugh Jackman and Tim Ferriss do Intermittent Fasting

Next: stop the data consumption! Start creating stuff by yourself. Reading/watching just grows your database of knowledge – and this world doesn't need more databases. Utilizing whatever knowledge you have so far to create something new – that’s what builds your smarts.

What’s the best way to get smarter?

I have read lots of books but forgotten most of them. What’s the purpose of reading?

I have read lots of books but forgotten most of them. What's the purpose of reading? by @jayanthrss

Answer by Jayanth sai Shiva:

I had the same question in my mind, but one story beautifully answered it.

Once a disciple asked his master the same question. “ I read so many books, but I don’t retain most of what I read, then whats the purpose of reading?”

Instead of answering him straight, the master gave him a dirty basket made of straw and asked him to fetch water from a nearby stream. (The bowl looked something like this, but imagine some dirt).

The disciple obeyed his master and filled it with water, but by the time he brought it back, the water drained. Master asked him to do it again. And then again and again and again.

Irritated, disciple asked, “Whats the use of this exercise, every time I bring water, it gets empty?”

Master said “Maybe the basket is empty, but look how clean it has become now. Same applies to books too. The basket is your mind and the water equivalent to books. You might not remember all the things you read but the way it transforms your mind is magnificent and sometimes incomprehensible.”

So, my dear friend,

Read because it gives you joy, not because it is utilitarian.

Read because it gives you wings without having to become a bird.

I have read lots of books but forgotten most of them. What's the purpose of reading?

Are you a self-made data scientist? How did YOU do it?

Are you a self-made data scientist? How did YOU do it? by Sudalai Rajkumar S

Answer by Sudalai Rajkumar S:

Here is one question which I think am qualified to answer for.!

I am a Mechanical Engineering graduate who had no prior knowledge about data science or for that matter even coding when I left my college six years back. Now I am working as a Lead Data Scientist in a reputed firm and also one of the top 25 Kaggle Data Scientists in the world.

Though I do not have formal background in CS or Statistics or Maths, I have a passion for crunching numbers and finding patterns right from my school days. I think anyone with a good passion for patterns and numbers coupled with right amount of hard work can become a self-made data scientist. Here is my path :

MOOC Courses:

This played a major role and is the first place in my learning path. Courses which helped me understand the basics concepts are

  1. Introduction to Statistics by Edx – This is very good introductory course in Statistics which taught me the basic concepts
  2. Machine learning course in Coursera – A very famous course by Andrew N G which most people are aware of
  3. Analytics Edge course in Edx – This is again a very good course with a lot of practical examples
  4. Statistical Learning by Standford Online – This is again a very good course by which teaches the concepts of predictive modeling in detail with R codes. The curriculum of the course closely follows this book

Some other nice online courses which I came across are

  1. Data Science by Harvard Extension – This is a very good course for people wanting to learn the concepts using python.
  2. Data Science and Engineering using Apache Spark by Edx – This is a very useful course for people starting with big data analytics
  3. Learning from Data by CalTech – This covers the basic concepts of machine learning
  4. Neural Networks for Machine Learning by Coursera – Interested in knowing about the new boy (Deep Learning) in town. This course is the perfect place for that taught by none other than Geoff Hinton himself.

Once I get a fair understanding of the DS concepts from these courses, I was itching to use them somewhere. I was looking for options to test these theoretical skills. That is when I came across DS / ML competitions.

DS / ML Competitions:

I came to know about Kaggle when I was searching for datasets to apply my learnings. I thought that I can ace the competitions easily since I have a good understanding of basic concepts. Poor me was not aware that hands-on is a different ball game from theory.

I started doing competitions on Kaggle but ended up at the bottom half of the table inspite of all the hard works. So once the competitions were over, I started looking at how others solved the problems from Kaggle Forums and blog. This is one important place where most of my learning took / taking place.

It also helped me hone my structured thinking on approaching the DS problems. It also helped me work on different real world datasets from different domains, each one challenging in its own way. When working deeper on these problems, I got new learnings every time and helped me improve myself further.

Doing Kaggle competitions at the first go might be daunting these days since the competition levels are quite high. So one can try to work on data science problems in other platforms like Analytics Vidhya Hackathons, Crowdanalytix, Driven Data etc before trying out on Kaggle to gain some confidence.

Other Sources:

Apart from MOOCs and DS competitions, two important sources that helped me with my learning and understanding of this space are

  1. KDNuggets
  2. Analytics Vidhya

I follow these two blogs to update my knowledge and to keep up myself to the advancements in the field.

Other resources which I found to be helpful are

  1. Data Science Central
  2. WildML blog
  3. Analytics India Magazine (To understand the happenings in India)
  4. MLWave blog
  5. FastML blog

Hope this helps other budding self-made data scientists.!

Are you a self-made data scientist? How did YOU do it?

What is the most clever life hack you’ve learned?

What is the most clever life hack you've learned? by Vimukthi Weerasiri

Answer by Vimukthi Weerasiri:

TLDR; Don’t change clothes just after you came home till you start the first productive activity

Let’s say you are coming from college and you have to do 10 home work questions,

What will someone typically do;

  1. Come home
  2. Change clothes, shower,…
  3. Do the 10 questions

What you do with this hack

  1. Come home
  2. Do 2 questions right away(DON’T CHANGE CLOTHES)
  3. change clothes, shower,…
  4. Do the other 8 questions

The point is when you walk/drive home and when you change clothes after that, you tend to chill and get into the “home” mood and lose time just doing nothing. So this hack saves that precious time.

I observed this first from one of the roommates I had in college. I don’t know whether he learned this or intuitively did this. But this works!

What is the most clever life hack you've learned?

What do you do if you know someone is lying but you don’t have any proof?

What do you do if you know someone is lying but you don't have any proof? by Krishna Suryakanth

Answer by Krishna Suryakanth:

Tell a lie to expose another lie. It works every time. Let me explain in three simple steps.

  1. Listen to the liar and collect data.
  2. Based on the data, create a lie.
  3. Catch the liar.

Example

I was at my cousin's home. He came home late after his college. On being asked, he said he had been to Pizza Hut with friends. He also told other details.

Based on the data provided I created a lie and I politely asked “Due to accident, road was blocked. How did you manage?”

He replied “Yes, we had to take a long route, that's why we got late

Clearly he was lying because there was no road accident and there was no blocked road. I just told a lie to catch another lie. He fell for the trap.

Hope this helps.

What do you do if you know someone is lying but you don't have any proof?

What is the most clever life hack you’ve learned?

What is the most clever life hack you've learned? by Deepak D

Answer by Deepak D:

Handwriting Analysis is an awesome thing to learn. You don't have to go into deep. But you need to know few simple things about handwriting, which may help you to know about a person from his/her/its handwriting. Let's begin,

✓Pressure you exert while writing

#Heavy- Deeply emotional person

#Light- Emotionally not expressive

✓Size of your letters

#Small- Good concentration, narrow perspective on life and better ability to focus on goals

Large- Broad perspective on life, hardly get bored

✓ Way of Handwriting slant

#Left- Introvert and independent

#Straight- Better at controlling emotions and hardly express them, usually prefers rational thoughts

#Right- This type of person is more likely to relate well to others but may subject to mood swings

✓Space in between letters

#Less- Bad at managing time, though likes to have company

#Even- Well sorted in life, good mental clarity and sense of order.

#Wide- Freedom lover, but don't like to be overwhelmed

✓Direction of your sentence take

#Upward- Optimistic

#Downward- Sign of discouragement

#Wavy- Sign of instability

✓The way you cross your 't'

#High cross- High standard and self esteem

#Low cross- Low self esteem and low level goals

✓The way you dot your 'i'

#Hollow dot(°)- Playful, creative

#Solid dot(•)- Don't like clutter and pay attention to details.

✓Connections of letters

#Connected- Logical, methodical and make decisions carefully

#Not connected- Intelligent and intuitive

✓Line spacing

#Little spacing- Poor time management

#Even spacing- Aware of boundaries

Did you find it interesting? No, then ask your friend to check your knowledge by asking to do analysis of unknown person, and then check his reaction. I know these things since last 6 years and it had never been wrong analysis from me. It worked for me. I hope it will work for you too.

After getting positive feedbacks, I am going to extend scope of this answer by adding one more thing, guess what? SIGNATURE ANALYSIS. I will not extend this answer by theory again. This one image will help you to analyse little bit.

[P.S.- This information is not work of mine. I have shared this info from internet, I found it useful. It has helped me in last 6 years. I wanted this information to be shared. If you find anything wrong then let me know. ]

What is the most clever life hack you've learned?

What is the difference between being wise, intelligent, and clever?

What is the difference between being wise, intelligent, and clever? by @Seanjkernan

Answer by Sean Kernan:

An intelligent person knows not to go into a dragon's cave to steal his gold.

A wise person chooses not to go into that cave.

A clever person tricks the dragon into leaving the cave so that he can go steal his gold.

What is the difference between being wise, intelligent, and clever?

What is the most clever life hack you’ve learned?

What is the most clever life hack you've learned? by Rohan Majji

Answer by Rohan Majji:

DIY Mosquito Trap

This might not be the most clever one, but it would be definitely worth knowing this simple hack.

Items required:

  1. A Plate (Ceramic plates are not suggestible).
  2. Oil

That’s it!

Wondering how would you make a mosquito trap using a simple plate and oil?

Here comes the hack.

Simple! Apply a thin-film of oil to the surface of the plate.

You can trap all the nearby mosquitoes just by swaying the plate and this works like a charm.

Fortunately, I’ve found a picture on the internet

IMAGE SOURCE: Pinterest

This hack was taught by my grandfather, They didn’t have any electrified Mosquito bats those days and most of the people relied on this technique. Kinda old but everyone would love doing this.

  • No Smoke
  • No Harmful Voltage
  • Can trap live mosquitoes 😉
  • All you need to do is, Swaying that plate like a mosquito bat.

Simple and Cool, Right?

EDIT 1: Guys, I don't know whether the mosquitoes get attracted to the oily plate. What I mean to say is, Manually bring this plate near the mosquitoes for better results.

Sway this instead of an electrified Mosquito Bat 😉

EDIT 2: Whoa! People are getting me wrong, The chance of mosquito getting trapped by itself is very less. What am I saying is manually bring this plate to the vicinity of the mosquito group and you can get a bunch.

No principle and other scientific stuff, please let me know if it has one.

**Excluding Surface Tension, Viscosity **

Mosquitoes stick to the Oily surface. That's all.

What is the most clever life hack you've learned?