LuckyPants
  • Home
  • Poems
  • Python
    • Python Interview Prep Notes for Students >
      • Merge Intervals Leetcode
      • Merge k Sorted Lists
    • Python Setup >
      • Pep 8 style guide
    • Lecture 1 - Basics
    • Lecture 2 - Loops, Lists >
      • Homework 2 Program 1 Step By Step
      • Homweork 2 Shuffle String Program
    • Lecture 3 - structures, packing, string functions >
      • Homework
      • Additional Exercises - you do not need to submit these
    • Lecture 4 - Dictionaries, Functions, Modules
    • Lecture 5 - functions, variable scope, modules >
      • Previous Exams
    • Lecture 6 - CLI, Files, Regex, pickle, shelve
    • Lecture 7 - capturing web content >
      • Processing XML data
    • Midterm Prep >
      • Programming assignment prep
    • Lecture 8 - Exceptions, Classes, Inheritance >
      • Exceptions Recording
      • Multiple Except Clauses Recording
      • Eating an Exception Recording
      • finally and else clause recordings
      • Exception Stack Trace Recording
      • exit() and CTRL+C
      • Class Variables Recording
      • Static Methods and Class Methods Recording
      • Inheritance Recordings
    • Section 9 - db, flask, pip >
      • Accessing Databases
      • HTTP Server
      • Web Applications
      • Finding and installing additional Libraries with pip
      • Web Services with Flask
      • Calling Web Services from Python
      • Placing your application on the web
    • Section 10 - flask, grpc, venv, docker >
      • Flask based Web Applications
      • gRPC
      • Packaging, Dependencies and Virtual Environments
      • Dockerized Python Application
    • Section 11 - Django, GUI >
      • Cross Site Scripting XSS and markupsafe
      • Django >
        • Cross Site Request Forgery CSRF
      • tkinter - frame and button
      • Toplevel
      • Frame
      • Mouse and Keyboard Events
      • Canvas
      • Menu
      • Radiobuttons and Checkboxes
      • Entry
      • ImageMagic
    • Lecture 12 - WebSockets, System Monitoring, PyGame >
      • Web Sockets
      • PyGame Platformer
    • Lecture 13 - Data Structure and Algorithms >
      • Arrays and Strings
      • Dictionaries
      • Linked Lists
      • Trees
      • Stack and Queue
      • Sets
      • Merge Sort
      • Coverage Reports
    • Lecture 14 - Subprocesses, Threads, Multiprocessing >
      • Graphs
      • Singleton Design Pattern
      • Subprocesses and Multithreading
      • Jupiter Notebooks
      • Pandas Operations
    • Extra >
      • Raspberry Pi
      • Raspberry PI home security
      • OpenCV and template matching
      • Compare SQLite DB's in Python
      • Natural Language Processing and nltk
      • Hackathon Projects
  • SaaS
    • Java Interview Prep Notes for Students
    • Setup >
      • SaaS and Cloud Computing
      • Eclipse set up
      • Building web application in Eclipse using Tomcat
    • Section2 >
      • Maven Intro
      • Set up a simple web app and deploy on Heroku
      • Add Jersey Dependencies
      • Dissecting our first REST service
    • Section3 >
      • Jackson intro
      • @POST, @PUT, @DELETE
      • Your Project
    • Section4 >
      • Rules of Injection
      • Root Resource, Subresource, Subresource Locator
      • @CONTEXT
    • Section 5 >
      • Heroku, Java, Jersey and Postgres
      • Music Store with Postgres
      • Working with Files
      • Storing files in Postgres
      • Homework
    • Section 6 >
      • Books Store with Mongo
      • Google APIs
      • Twitter APIs
      • Properties for a web application
      • Homework
    • Section 7 >
      • Jersey Client Famework
      • Java Jersey SalesForce and OAuth
      • Servlets and JSP
      • Data access examples
    • Section 8 >
      • MVC - Model View Controller
      • JSTL Core tags
      • Scopes
      • Building Services to work with forms
    • Section 9 >
      • Calling REST services with JQuery
      • Angular.js
    • Section 10 >
      • consuming SOAP services
      • Web Sockets
      • Websockets, continued
    • Section 11 - Software Development Methodologies, Testing, Performance and Security >
      • Software Development Methodologies
      • Testing, Performance and Security
    • Your Project
    • Previous Projects
    • Course Project Submission
    • SaaS Projects
    • Install Tomcat on Mac

Meeting Rooms

11/8/2020

0 Comments

 
Given an array of meeting time intervals where intervals[i] = [starti, endi], determine if a person could attend all meetings.


Example 1:
Input: intervals = [[0,30],[5,10],[15,20]] Output: false Example 2:
Input: intervals = [[7,10],[2,4]] Output: true

Constraints:
  • 0 <= intervals.length <= 104
  • intervals[i].length == 2
  • 0 <= starti < endi <= 106​
use following skeleton:
def canAttendMeetings(intervals):
    pass

int = [[0,30],[5,10],[15,20]] 
print(canAttendMeetings(int)) #False

int = [[7,10],[2,4]]
print(canAttendMeetings(int)) #True

int = [[13,15],[1,13]]
print(canAttendMeetings(int)) #True

int = [[17,20],[17,20]]
print(canAttendMeetings(int)) #False
0 Comments

Claculator

11/3/2020

0 Comments

 
Given an arithmetic equation of positive integers, +, -, * and / (no parentheses) compute the result

2*3 + 5/6*3+15

Output: 23.5
0 Comments

Clone Graph

10/30/2020

0 Comments

 
Leetcode Clone Graph: ​https://leetcode.com/problems/clone-graph/
0 Comments

Is String a Rotation

10/28/2020

0 Comments

 
String Rotation (cracking coding interview):
Assume you have a method isSubstring which checks if one word is a substring of another. Given two strings, s1 and s2, write code to check if s2 is a rotation of s1 using only one call to isSubstring (eg: "waterbottle" is a rotation of  "erbottlewat")
0 Comments

SHUFFLE THE ARRAY

10/25/2020

0 Comments

 
Shuffle the array: https://leetcode.com/problems/shuffle-the-array/ (Links to an external site.)


Given the array nums consisting of 2n elements in the form [x1,x2,...,xn,y1,y2,...,yn].
Return the array in the form [x1,y1,x2,y2,...,xn,yn].


Example 1:
Input: nums = [2,5,1,3,4,7], n = 3 Output: [2,3,5,4,1,7] Explanation: Since x1=2, x2=5, x3=1, y1=3, y2=4, y3=7 then the answer is [2,3,5,4,1,7]. Example 2:
Input: nums = [1,2,3,4,4,3,2,1], n = 4 Output: [1,4,2,3,3,2,4,1] Example 3:
Input: nums = [1,1,2,2], n = 2 Output: [1,2,1,2]

Constraints:
  • 1 <= n <= 500
  • nums.length == 2n
  • 1 <= nums[i] <= 10^3
class Solution:
    def shuffle(self, nums: List[int], n: int) -> List[int]:
        t =[]
        for i in range(0, n):
            t.append(nums[i])
            t.append(nums[i+n])
        return t
0 Comments

REMOVE DUPES

10/25/2020

0 Comments

 
Write a code to remove duplicates from an unsorted linked list
Solution from Krunal
​Runs in O(n), the set lookup is constant time because set implementation in Python is hashtable
class Node(object):

    def __init__(self, data=None, next_node=None):
        self.data = data
        self.next_node = next_node

    def get_data(self):
        return self.data

    def get_next(self):
        return self.next_node

    def set_next(self, new_next):
        self.next_node = new_next

    @staticmethod
    def print_list(start_at):
        if start_at != None:
            print(start_at.data)
            Node.print_list(start_at.next_node)

    @staticmethod
    def remove_duplicates(head):
        hashSet = set()
        hashSet.add(head.data)
        prev = head
        current = head.next_node

        while (current):
            if current.data in hashSet:
                prev.next_node = current.next_node
                current = current.next_node
            else:
                hashSet.add(current.data)
                prev = current
                current = current.next_node

head = Node(1)
walker = head

for i in [1,2,1,3,4,3,3,3,4,5,6,7,8,9,9]:
   walker.next_node = Node(i)
   walker = walker.next_node

Node.print_list(head)




Node.remove_duplicates(head)

print("after removing duplicates")

Node.print_list(head)
0 Comments

5 Resume Writing Tips for Software Engineers

10/10/2020

1 Comment

 
I'd like to point out that this is my personal opinion based on my past experience, not supported by any research or formal education.  I also suggest going through this link that has good tips on formatting the resumes and content.

1. Start with LinkedIn

That's where most recruiters find their candidates. Make your LinkedIn profile presentable, list experience, skills, certifications, education that will turn into keywords and your profile becomes searchable so that recruiters can find you. Do ask for Recommendations to go on your LinkedIn profile. It takes an effort to write a recommendation and the person is willing to put their name next to it, hence number of nice recommendations do leave positive impression. 

2. Serve different audiences well

Your resume will be reviewed by recruiters, hr personnel, hiring manager and the development team. They have different goals and will be looking for different things on your resume. You need to help them find the information they need fast. But how fast? Let's go through goals for each of the types of people:

The goal for Recruiters is to find as many job description matching candidates as possible.  They go through dozens of resumes a day for different roles and they usually have the people they are looking for described in just few words. If you don't give them the information they need within seconds of them glancing at your resume, they will toss it. So what are usually those keywords that are given to recruiters? 
  • Years of experience
  • 1-3 skills
  • Education
  • 1-2 backgrounds
For example, recruiter may be asked to find Python engineer with at least BS degree, some machine learning in their profile, who comes from a large company (they may also have a list of companies they would prefer their candidates from).  This information needs to be found fastest, always list most recent experience/education on top of the section. Do not overload your resume with the skills you have already forgotten. 


The main concern for HR is that the candidate meets the job description  and they will also read through your resume, usually in more detail. There will be few things that can raise red flags and cause your resume be tossed at this point:
  • Scattered experience, short employment spans that repeat more than 1 time,  more than 1 gaps in employment. This may send a message of lack of commitment  
  • Different part of resume written in different styles. Sometimes it may appear as if the resume was copy-pasted from many other resumes - some experience written in first person, some in third person; some focuses only on technical description of the project, some  only on financial benefits.  
  • Grammar mistakes. 
  • Over-bragging - for example, 100 skills listed that take up half of the resume
HR also needs to be able to skim through your resume fast, hence be concise and only list only what's truly relevant.

The goal for Hiring manager and the team is to find someone who will get the job done, create least amount of problems and will mesh well with the team. These are the people who will reject most of the resumes after recruiters sifted through them but before they even meet the candidates. They will usually understand every sentence you have written about your experience and will be able to call out BS immediately. So, don't BS on your resume. 
It is better if you write everything up in your unpolished language than try to copy from some other impressive profiles online. Explain your projects/experience in as few words as possible but keep in mind - hiring managers don't know your domain/systems. So explain what overall system did, for example  - "Customer portal that lets customers access their billing and service information" and then describe what you did, for example - "I built the back-end API in .Net core that connected to relational DB and provided information to the front-end systems in a secure manner". There are few things that may score some brownie points on the resume:
  • Certifications - these show the candidate is able to stick to and achieve goals independently
  • High GPA for recent grads - since you do not have lot of experience, your GPA may make the difference
  • Open source projects contributions or starting your own, meaningful open source project. First is more impressive than latter unless latter grew into something big

Again, being concise and to the point is important to get all the info the hiring manager needs fast, hence the next tip. 

3. One page only, please

No matter how much experience you have, you can fit it all on 1 page. Or you can do what I usually do - have 1 page concise resume and details on the following pages. Don't argue, just do it, trust me on this one. 

4. Ask your friends and family for feedback

Try to ask other software engineers for feedback and obviously, the more experience they have the better. Some people will have very good critical feedback, some not so much. It is up to you what you do with it, but make sure to listen to every one of them, don't argue, ask questions and thank them for the help. You may not agree with them, but they took time out of their lives to help you and you don't want to lose that. If you do incorporate their feedback into your resume, share the updated resume with them.  

5. Add github link and links to any other technical accounts

Nothing can showcase your work better than, well, your work. Organize your public github account well, help with open source projects or work on some nice projects on your own, have frequent commits and clean code. If you have other technical accounts that can be publicly viewed on the web or some publicly hosted projects, showcase that. 

1 Comment

If an element in an MxN matrix is 0, set the row and column to 0

10/4/2020

0 Comments

 
Write an algorithm such that if an element in an MxN matrix is 0, its entire row and column are set to 0
a = [
[2,3,4,5,6],
[2,3,0,5,6],
[2,3,4,5,6],
[2,3,4,5,6],
[2,3,4,5,0]
]
print("BEFORE")
for p in a:
        print(p)
zero_cols=[]
zero_rows=[]

for i in range(len(a)):
        for j in range(len(a[0])):
                if(a[i][j] == 0):
                        zero_cols.append(j)
                        zero_rows.append(i)

for i in range(len(a)):
        for j in range(len(a[0])):
                if(i in zero_rows):
                        a[i][j] = 0
                if(j in zero_cols):
                        a[i][j] = 0
                        
print("AFTER")
for f in a:
        print(f)
0 Comments

Child On a Staircase

10/4/2020

0 Comments

 
A child is running a staircase with n steps, and can hop either 1 step, 2 steps, or 3 steps at a time. Implement a function to count how many possible ways the child can run up the stairs
​
def possibleWays(steps, possibilities):
        if(steps == 0):
                return 1;
        if(steps < 0):
                return 0;

        return possibleWays(steps-1, possibilities)+possibleWays(steps-2, possibilities)+possibleWays(steps-3, possibilities)

print(possibleWays(3, 0))
0 Comments

Rotate Matrix 90 degrees

10/4/2020

0 Comments

 
Given an NxN matrix, write a function that would rotate it by 90 degrees clock-wise or counter clockwise

So, given something like this:


[2, 3, 4, 5]
[2, 3, 4, 5]
[2, 3, 4, 5]
[2, 3, 4, 5]

we would end up with something like (counter clock-wise):

[5, 5, 5, 5]
[4, 4, 4, 4]
[3, 3, 3, 3]
[2, 2, 2, 2]

or (clock-wise):


[2, 2, 2, 2]
[3, 3, 3, 3]
[4, 4, 4, 4]
[5, 5, 5, 5]
a = [
[2,3,4,5,6],
[2,3,4,5,6],
[2,3,4,5,6],
[2,3,4,5,6],
[2,3,4,5,6]
]
print("BEFORE")
for p in a:
        print(p)

for i in range(len(a)):
        for j in range(len(a)-i):
                a[i][j], a[len(a)-j-1][len(a)-i-1] = a[len(a)-j-1][len(a)-i-1],a[i][j]
                
print("AFTER")
for f in a:
        print(f)
output:

BEFORE

[2, 3, 4, 5, 6]
[2, 3, 4, 5, 6]
[2, 3, 4, 5, 6]
[2, 3, 4, 5, 6]
[2, 3, 4, 5, 6]

AFTER

[6, 6, 6, 6, 6]
[5, 5, 5, 5, 5]
[4, 4, 4, 4, 4]
[3, 3, 3, 3, 3]
[2, 2, 2, 2, 2]

​
0 Comments
    This section is for interview problems and solutions, also the interview tips for my Python students

    Categories

    All
    Cracking Coding Interview
    Leetcode
    Resume

  • Home
  • Poems
  • Python
    • Python Interview Prep Notes for Students >
      • Merge Intervals Leetcode
      • Merge k Sorted Lists
    • Python Setup >
      • Pep 8 style guide
    • Lecture 1 - Basics
    • Lecture 2 - Loops, Lists >
      • Homework 2 Program 1 Step By Step
      • Homweork 2 Shuffle String Program
    • Lecture 3 - structures, packing, string functions >
      • Homework
      • Additional Exercises - you do not need to submit these
    • Lecture 4 - Dictionaries, Functions, Modules
    • Lecture 5 - functions, variable scope, modules >
      • Previous Exams
    • Lecture 6 - CLI, Files, Regex, pickle, shelve
    • Lecture 7 - capturing web content >
      • Processing XML data
    • Midterm Prep >
      • Programming assignment prep
    • Lecture 8 - Exceptions, Classes, Inheritance >
      • Exceptions Recording
      • Multiple Except Clauses Recording
      • Eating an Exception Recording
      • finally and else clause recordings
      • Exception Stack Trace Recording
      • exit() and CTRL+C
      • Class Variables Recording
      • Static Methods and Class Methods Recording
      • Inheritance Recordings
    • Section 9 - db, flask, pip >
      • Accessing Databases
      • HTTP Server
      • Web Applications
      • Finding and installing additional Libraries with pip
      • Web Services with Flask
      • Calling Web Services from Python
      • Placing your application on the web
    • Section 10 - flask, grpc, venv, docker >
      • Flask based Web Applications
      • gRPC
      • Packaging, Dependencies and Virtual Environments
      • Dockerized Python Application
    • Section 11 - Django, GUI >
      • Cross Site Scripting XSS and markupsafe
      • Django >
        • Cross Site Request Forgery CSRF
      • tkinter - frame and button
      • Toplevel
      • Frame
      • Mouse and Keyboard Events
      • Canvas
      • Menu
      • Radiobuttons and Checkboxes
      • Entry
      • ImageMagic
    • Lecture 12 - WebSockets, System Monitoring, PyGame >
      • Web Sockets
      • PyGame Platformer
    • Lecture 13 - Data Structure and Algorithms >
      • Arrays and Strings
      • Dictionaries
      • Linked Lists
      • Trees
      • Stack and Queue
      • Sets
      • Merge Sort
      • Coverage Reports
    • Lecture 14 - Subprocesses, Threads, Multiprocessing >
      • Graphs
      • Singleton Design Pattern
      • Subprocesses and Multithreading
      • Jupiter Notebooks
      • Pandas Operations
    • Extra >
      • Raspberry Pi
      • Raspberry PI home security
      • OpenCV and template matching
      • Compare SQLite DB's in Python
      • Natural Language Processing and nltk
      • Hackathon Projects
  • SaaS
    • Java Interview Prep Notes for Students
    • Setup >
      • SaaS and Cloud Computing
      • Eclipse set up
      • Building web application in Eclipse using Tomcat
    • Section2 >
      • Maven Intro
      • Set up a simple web app and deploy on Heroku
      • Add Jersey Dependencies
      • Dissecting our first REST service
    • Section3 >
      • Jackson intro
      • @POST, @PUT, @DELETE
      • Your Project
    • Section4 >
      • Rules of Injection
      • Root Resource, Subresource, Subresource Locator
      • @CONTEXT
    • Section 5 >
      • Heroku, Java, Jersey and Postgres
      • Music Store with Postgres
      • Working with Files
      • Storing files in Postgres
      • Homework
    • Section 6 >
      • Books Store with Mongo
      • Google APIs
      • Twitter APIs
      • Properties for a web application
      • Homework
    • Section 7 >
      • Jersey Client Famework
      • Java Jersey SalesForce and OAuth
      • Servlets and JSP
      • Data access examples
    • Section 8 >
      • MVC - Model View Controller
      • JSTL Core tags
      • Scopes
      • Building Services to work with forms
    • Section 9 >
      • Calling REST services with JQuery
      • Angular.js
    • Section 10 >
      • consuming SOAP services
      • Web Sockets
      • Websockets, continued
    • Section 11 - Software Development Methodologies, Testing, Performance and Security >
      • Software Development Methodologies
      • Testing, Performance and Security
    • Your Project
    • Previous Projects
    • Course Project Submission
    • SaaS Projects
    • Install Tomcat on Mac