Coding interview preparation
5.81K subscribers
375 photos
55 files
163 links
Download Telegram
Top Programming Interview Questions and Answers (General)

Question: Please explain what you understand by computer programming.
Answer:
Also known as coding or programming, computer programming is the process of encoding an algorithm into a notation, typically a computer program, by means of some programming language so that it can be executed by a computer.

Each programming language contains a set of instructions for the computer to execute a set of tasks. Programming is a complex process that includes designing an algorithm, coding the same in a programming language, debugging a program, maintaining, and updating the code.

Question: Can you enumerate and explain the various types of errors that can occur during the execution of a computer program?
Answer
: Three types of errors can occur during the execution of a computer program. These are:

Logical errors – This occurs in the scenario of a computer program implementing the wrong logic. As there is no report generated for these types of programming errors, they are the most difficult ones to deal with.
Runtime errors – Occurs when the program contains an illegal operation. For example, dividing a number by 0. These are the only errors that are displayed instantly during the program execution. Upon the occurrence of a runtime error, the program execution is stopped and a diagnostic message is displayed.
Syntax errors – Occurs when one or more grammatical rules of the programming language being used is violated. Such errors are detected during compile time.

Question: Please explain an algorithm. What are some of its important features?
Answer
: An algorithm can be defined as a set of finite steps that when followed helps in accomplishing a particular task. Important features of an algorithm are clarity, efficiency, and finiteness.

Question: What do you understand by maintaining and updating a computer program?
Answer
: The maintenance and updating process of a computer program starts post its successful installation. While program maintenance is the continuous process of monitoring the computer program for bugs and errors, updating the computer program means making it better with minor and major changes over time.

Question: Please provide a brief explanation on variables.
Answer
: Variables are used for storing the input of a program as well as the computational results during program execution. These are actually named memory locations. The value stored in a variable can change during the program execution.

Source: Vijay Singh
From my experience, the best programming questions are the ones that have multiple approaches with different trade-offs. Observing someone tackle the same problem under different constraints can teach you a lot about the person's attitude and abilities. I'll give a concrete example, and then explain why I think it's a great question.


Problem**: Let's say you have a list of N+1 integers between 1 and N. You know there's at least one duplicate, but there might be more. For example, if N=3, your list might be 3, 1, 1, 3 or it might be 1, 3, 2, 2. Print out a number that appears in the list more than once. (That is, in the first example, you can print '1' or '3' -- you don't have to print both.)

[Pause here if you want to think about the problem because I'm about to give away the solution.]

Here's an idealized conversation:

Interviewer: [states problem]

Candidate: Well, I guess the most obvious approach is to compare every number in the list to every other number until you find a duplicate.

Interviewer: That's a good start. What are the space and time complexities of that solution?

Candidate: O(n^2) time and O(1) space.

Interviewer: Great. Okay, well let's say the list is pretty big, so you need something that's faster than O(n^2).

Candidate: Hm, I guess I could iterate through the list and use a hash to keep track of the values I've seen so far. Once I encounter a number that's already in the hash, I am done.

Interviewer: That's a good idea, but does it need to be a hash given that all of the inputs are integers between 1 and N?

Candidate: Ah, I guess I could just use a boolean array and use the integer values as indices.

Interviewer: What are the space and time complexities of that solution?

Candidate: O(n) time to iterate through the list and O(n) space for the array/hash.

Interviewer: Very good. Okay, let's say the list of numbers is quite large, so you'd like to avoid creating a copy of it. Maybe you have 8GB of RAM, and the list takes up 6GB.

Candidate: Well, I could sort the numbers and compare adjacent pairs. That would take O(n*log n) time and O(1) space if I use an in-place sort like mergesort.

Interviewer: Excellent. Let's throw in one final constraint: what if you want something faster than O(n^2) and you can't afford to use a lot of extra space, but you also can't manipulate the original list. For example, maybe the list is on a read-only CD.

(Almost every candidate needs a hint or two at this point..)

Candidate: I think I can binary search for a duplicated number. For example, I go through the list and count the number of integers between 1 and N/2. If the count is greater than the number of possible integers in that range, then I know there's a duplicate in that range. Otherwise, a duplicate must exist in the range of N/2+1 to N. Once I know which half of the range the duplicate is in, I can recurse and binary search in that half, then keep repeating the process until I've found a duplicated number. The time complexity is O(n*log n) and the space complexity is O(1).

Interviewer: When can you start?
Questions like this are great because they test so many things at the same time:

πŸ”ΉThe candidate's general competence with algorithms, space/time complexity, etc.
πŸ”ΉThe candidate's ability to respond to different constraints and handle various trade-offs. This is something engineers deal with all of the time, and it's a critical skill to have.
πŸ”ΉThe candidate's creativity. Each constraint forces a person to start from scratch and think of a completely new approach -- a great test of creativity.
πŸ”ΉThe candidate's attitude toward complexity. Some candidates get permanently stuck because they start off by trying to come up with the O(n*log n) time / O(1) space solution. They assume that using a hash or comparing all elements of the list to all other elements is not what you're looking for, and so they don't mention the easy solutions (but also can't figure out the harder solutions). This is a yellow flag that the candidate tends to overcomplicate things (I'll typically ask subsequent interviewers to watch out for this tendency).
πŸ”ΉThe candidate's passion for learning and challenges. Some people get excited when you throw in harder and harder constraints, others get dejected and/or lazy.

** To give credit where credit is due, I was asked this question during an interview at Microsoft. I thought it was a great question and have been using it myself ever since. Quora seems like a good place to retire the question and force myself to think of something more original =).

Source: Leo Polovets
One of important questions on programming interviews is related to program efficiency and performance.

Why analysing efficiency is important?
Suppose computers were infinitely fast and computer memory was free. Would you have any reason to study algorithms? But the reality is: computers may be fast but not infinitely fast, and memory may be inexpensive but not free. So, running time and space are essential resources for defining the performance of the computer program. Think!

In computer science, these things are as crucial as an algorithm’s performance: Correctness of a code, Functionality, User Friendliness, Modularity, Scalability, Security, Maintainability, Programmers time. But the critical question is : why do we analyze the performance of an algorithm? Here are a few important reasons:
πŸ”ΉThe performance draws a line between feasible and infeasible.
πŸ”ΉIt provides a clean standard to think about the program or system behavior.
πŸ”ΉPerformance is just like money where we use it to pay for more functionality or user-friendliness. For example, we code in Java or C++ for the OOPS features, even though Java or C++ is approx. 3 times slower than C. In other words, we are willing to pay the performance by a factor of 3 to get more functionalities.
πŸ”ΉSpeed is always fun and we love it!

Source: EnjoyAlgorithms
How to prepare for coding interview
Interview Preparation Plan for 30 Days: 200+ coding and Behavioural questions

Table of contents

Day 1: Arrays
Day 2: Sorting
Day 3: Searching
Day 3: Matrix
Day 4: Sliding Window Patten
Day 5: Maths
Day 6 & 7: Linked list
Day 8: 2 Pointer
Day 9: Fast & Slow Pointers
Day 10: Stack
Day 11: Queue
Day 12: Hashing
Day 13 & 14: Heap
Day 15: Greedy
Day 16: Recursion
Day 17: Backtracking
Day 18: Divide & Conquer
Day 19: String
Day 20 & 21: Binary Tree
Day 22: Binary Search Tree
Day 23: Mixed Topics
Day 24: Graph
Day 25 & 26: Dynamic Programming
Day 27: Design Patterns
Bits Manipulation (optional)
System Design β€” Key Concepts and Terms (Interview notes)
Day 28 & 29: Theory (OS, CN, DB) (To be added)
Day 30: Behavioural Interview (To be added)
Day 30: Projects (How to discuss projects in interviews)

πŸ”— Link:
https://ganeshpr227.medium.com/30-days-interview-preparation-plan-200-best-coding-questions-and-behavioural-interviews-3f8fc19c2361
❀1
Computer Science 61B, 002 - Spring 2015
Data structures
by UC Berkeley


πŸ‘¨β€πŸ« Teacher: Joshua A. Hug
🎬 37 video lessons
⏰ 35 hours
βœ… Free

πŸ”— Course link

#datastructures #algorithms #cs #dsa
βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–
πŸ‘‰Join @bigdataspecialist for moreπŸ‘ˆ
Websites for finding a job

WayUp - is the industry leader for college students and recent grads to get hired

NovoResume - The Idea of Novorésumé began in 2014, Cristian, Andrei, and Stefan started as part of a university project. The idea was to solve the problem of many people who have really good skills and experience but don't know how to showcase it in Resumes, CVs, and Cover Letters.

Glassdoor - This platform, helps you search millions of jobs and companies and get the inside information on companies like employee reviews, salary for different Jobs at that company, and much more.

AngelList - Help you Apply for more than 130,000 jobs in startups with one application.

PayScale - If you want to know your "WORTH" in terms of your skills and experience. If you want to measure your skills and their worth in the market. You can use this platform.

Salary - Helps you measure and understand your worth and also helps planning your next move in your career with easy-to-use features.

LinkedIn - LinkedIn is the world's largest network of professionals. It has nearly 660+ million users. It is present in more than 200 countries and territories worldwide.

HashNode - Hashnode Helps you easily connect with the best developers around the world and help you grow your career!

levels.fyi - It helps to break down the total salary packages at the largest tech companies. for multiple levels of software engineers.

Indeed - Helps you Search for millions of jobs online, find the next move in your career. It has features like job search, resumes, company reviews, salary, etc.



βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–
Join @coding_interview_preparation for more.
*This channel belongs to @bigdataspecialist group
πŸ”— Book link


#machinelearning #ml #datascience
βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–
Join @coding_interview_preparation for more.
*This channel belongs to @bigdataspecialist group
I accidentally run across this today, thought it might be interesting to share:

Wizardzines questions
Questions is an unusual medium designed by Julia Evans in which the form of the writing is a series of questions.
This site is made to help you identify things you don't know, because the only way to learn new things is to first find out what you don't know

πŸ”— Link:
https://questions.wizardzines.com/

βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–
Join @coding_interview_preparation for more.
*This channel belongs to @bigdataspecialist group
Retaining Computer Science Knowledge

Back at University, I didn't have problems remembering things, I was preparing one exam at the time and reviewing my knowledge all the time.
But now after 3 years of working as backend developer and data scientist, I really have problem to remember what I learned just few months ago. It feels like it's completely deleted from my brain. I guess main reason for that (except aging πŸ˜›) is not revising what i learned.

This article is talking about how to retain your computer science knowledge:

https://startupnextdoor.com/retaining-computer-science-knowledge/

βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–
Join @coding_interview_preparation for more.
*This channel belongs to @bigdataspecialist group
LeetCode Solutions Videos

Good explanations of solution and the code
Playlist contains 189 videos 🎬

https://www.youtube.com/playlist?list=PLU_sdQYzUj2keVENTP0a5rdykRSgg9Wp-

βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–
Join @coding_interview_preparation for more.
*This channel belongs to @bigdataspecialist group
What are the most common programming interview questions?

Companies keep refreshing and updating questions. BUT, regardless of that, there are certain algorithms that show up frequently.

Here are 5 very common ones. If you don’t know these then you’re probably not ready.

Graph Search - Depth-first and Breadth-first search
Binary Search
Backtracking using Recursion and Memoization
Searching a Binary Search Tree
Recursion over a Binary Tree

Of course, there are many others too.

Another thing to keep in mind - you won’t be asked these directly. It will be disguised as a unique situation.

Source: Harsh Goel

βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–
Join @coding_interview_preparation for more.
*This channel belongs to @bigdataspecialist group
Here are some good questions to ask at the end of the interview, extracted from various sources. The ones in bold are the ones that tend to make the interviewer go "That's a good question" and pause and think for a bit.


πŸ”ΉGeneral

What are you most proud about in your career so far?
What is the most important/valuable thing you have learned from working here?
How do your clients and customers define success?
What would you change around here if you could?
What are some weaknesses of the organization?
What does a typical day look like for you?
What do you think the company can improve at?
How would you see yourself growing at this company in the next few years?
Was there a time where you messed up and how was it handled?
Why did you choose to come to this company?
When you were last interviewing, what were some of your other options, and what made you choose this company?
What was something you wish someone would have told you before you joined?
What was your best moment so far at the company?

πŸ”ΉCulture

What is the most frustrating part about working here?
What is unique about working at this company that you have not experienced elsewhere?
What is something you wish were different about your job?
How will the work I will be doing contribute to the organization's mission?
What do you like about working here?
What is your policy on working from home/remotely?
(If the company is a startup) When was the last time you interacted with a founder? What was it regarding? Generally how involved are the founders in the day-to-day?
Does the company culture encourage entrepreneurship? Could you give me any specific examples?

πŸ”ΉTechnical

These questions are suitable for any technical role.

What are the engineering challenges that the company/team is facing?
What has been the worst technical blunder that has happened in the recent past? How did you guys deal with it? What changes were implemented afterwards to make sure it didn't happen again?
What is the most costly technical decision made early on that the company is living with now?
What is the most fulfilling/exciting/technically complex project that you've worked on here so far?
I do / don't have experience in domain X. How important is this for me to be able to succeed?
How do you evaluate new technologies? Who makes the final decisions?
How do you know what to work on each day?
How would you describe your engineering culture?
How has your role changed since joining the company?
What is your stack? What is the rationale for/story behind this specific stack?
Do you tend to roll your own solutions more often or rely on third party tools? What's the rationale in a specific case?
How does the engineering team balance resources between feature requests and engineering maintenance?
What do you measure? What are your most important product metrics?
What does the company do to nurture and train its employees?
How often have you moved teams? What made you join the team you're on right now? If you wanted to move teams, what would need to happen?
What resources does the company have for new hires to study its product and processes? Are there specifications, requirements, documentation?
There's "C++" (or Python, Swift or any other tech) in the job description. How will you estimate my proficiency in this tech in 3 months?
How do you think my expertise would be relevant to this team? What unique value can I add?
πŸ”ΉProduct

Tell me about the main products of your company.
What is the current version of product? (If it is v1.0 or similar - there could be a lot of chaos to work with)
What products are your main competitors?
What makes your product competitive?
When are you planning to provide the next release? (If in several months, it would mean a lot of requirements specified in job description are not needed right now)
Is the team growing, and what sort of opportunities will there be in the next year/3 years?
What are your highest priorities right now? For example, new features, new products, solidifying existing code, reducing operations overhead?

πŸ”ΉManagement

These questions are suitable for asking Engineering Managers, especially useful for the Team Matching phase of Google interviews or post-offer calls that your recruiters set up with the various team managers.

How do you train/ramp up engineers who are new to the team?
What does success look like for your team/project?
What qualities do you look out for when hiring for this role?
What are the strengths and weaknesses of the current team? What is being done to improve upon the weaknesses?
Can you tell me about a time you resolved an interpersonal conflict?
How did you become a manager?
How do your engineers know what to work on each day?
What is your team's biggest challenge right now?
How do you measure individual performance?
How often are 1:1s conducted?
What is the current team composition like?
What opportunities are available to switch roles? How does this work?
Two senior team members disagree over a technical issue. How do you handle it?
Have you managed a poor performer at some point in your career before? What did you do and how did it work?
Where do you spend more of your time, high performers or low performers?
Sometimes there's a trade-off between what's best for one of your team members and what's best for the team. Give an example of how you handled this and why.
Give an example of a time you faced a difficult mentoring/coaching challenge. What did you do and why?
What is your management philosophy?
What is the role of data and metrics in managing a team like ours?
What role does the manager play in making technical decisions?
What is an example of a change you have made in the team that improved the team?
What would be the most important problem you would want me to solve if I joined your team?
What opportunities for growth will your team provide?
What would I work on if I joined this team and who would I work most closely with?

πŸ”ΉLeadership

These questions are intended for senior level management, such as CEO, CTO, VPs. Candidates who interview with startups usually get to speak with senior level management.

How are you funded?
Are you profitable? If no, what's your plan for becoming profitable?
What assurance do you have that this company will be successful?
Tell me about your reporting structure.
How does the company decide on what to work on next?

πŸ”ΉHR

How do you see this position evolving in the next three years?
Who is your ideal candidate and how can I make myself more like them?
What concerns/reservations do you have about me for this position?
What can I help to clarify that would make hiring me an easy decision?
How does the management team deal with mistakes?
If you could hire anyone to join your team, who would that be and why?
How long does the average engineer stay at the company?
Why have the last few people left?
Have you ever thought about leaving? If you were to leave, where would you go?
What programming language is fastest among offered ones
Anonymous Quiz
13%
JavaScript
2%
PHP
30%
C
37%
Python
3%
Ruby
1%
Perl
13%
Java
Coding interview preparation
What programming language is fastest among offered ones
Out of 154 answers only 29% answered correctly. I guess we should start some training in this channel, from basic level :D

Most of you answered Python, yes it's easy to write code in Python, easier than in other programming languages, but the fact that it's to easy makes it really slow when it comes to computation.

In Python you don't have to write types of variables, but since you don't write it, it means computer needs to figure out type instead of you in runtime, which makes him slow.

Also Python is interpreted language, which means it Interpreter need to read and execute code in runtime. On the other hand, Java or C are compiled programming languages which means that your computer directly translates the program to machine code which could be understood by computer. This is done before you run your code, so no time is lost for conversion in runtime.

Btw if you didn't now, Python is created using C language, so when you run Python there are some C commands running underneath πŸ˜‰
Hey guys,
I have created basic programming quiz. Quiz has 8 questions with multiple answers. When you finish it, you will get your position on the leaderboard.

This is first test quiz, if you like it we will create more and maybe even give some prizes to best ones on leaderboards. Your answers will remain anonymous.

You can take the quiz here:
http://t.me/QuizBot?start=Qf9xzJIx
Should we share quiz results publicly?
Anonymous Poll
11%
No
9%
Only top 3
10%
Only top 10
13%
Only top 20
56%
Share all