You are watching: Elements of programming interviews in python pdf

Page 3

Elements ofProgrammirgIntenriews in PythonThe lnsiders' GuideAdnan AzizTsung-Hsien LeeAmit PrakashElementsOf Programming

Page 4
Page 5

To my Aziz,father,lshrat because that gk:ing tne my lifelong loae that learningAdnan AzizTo my parents, Hsicn-Kuo ke andTseng-Hsi"a Li,for the eaerlasting support and also looe lock gioe meTsung-Hsien LeeTo rny parents, Manju Shree and Arun Praknsh,the most loaing parental I can imagineAmit Prakash

Page 7

Thble of Contentslntroduction 1I The Interview 5L gaining Ready 62 techniques For A an excellent Interview 133 Conducting one Interview 19il Data Structures and also Algorithms 224 Primitive species 234.7 computing the parity of a word 244.2 Swap bits 274.3 turning back bits 284.4 find a the next integer with the very same weight 284.5 Compute r x y without arithmetical operator 294.6 Compute xlV . . 314.7 Compute x/ 324.8 turning back digits . 324.9 examine if a decimal creature is a palindrome . JJ4.10 generate uniform arbitrarily numbers 344.77 Rectangle intersection 355 Arrays 375.1 The Dutch nationwide flag problem 395.2 Increment one arbitrary-precision integer 435.3 Multiply 2 arbitrary-precision integers 435.4 advancing through range 445.5 Delete duplicates indigenous a sorted range . 455.6 Buy and sell a stock as soon as 465.7 Buy and sell a stock double 47I

Page 8

I r -trll:--tr-rrtltl5.8 computing an altemation 485.9 Enumerate every primes come n 495.10 Permute the elements of range . 505.11 Compute the next permutation 525.12 Sample offline data 545.13 Sample online data 555.1.4 Compute a arbitrarily permutation 565.15 Compute a arbitrarily subset 575.1.6 create nonuniform arbitrarily numbers 585.17 The Sudoku checker trouble 605.18 Compute the spiral bespeak of a2D affay . 615.19 turn a2D array 645.20 Compute rows in Pascal's Triangle 655 Strings 676.1 Interconvert strings and also integers 686.2 base conversion 696.3 Compute the spreadsheet column encoding . 706.4 Replace and also remove 716.5 Testpalindromicity 726.6 turning back all the indigenous in a sentence 736.7 Compute all mnemonics for a call number 746.8 The look-and-say difficulty 756.9 convert from roman to decimal 766.10 Compute every valid IP addresses 776.77 create a string sinusoidallY 786.12 perform run-length encoding 796.13 find the an initial occurrence that a substring . . . . 797 connected Lists 827.1 Merge 2 sorted list 847.2 reverse a single sublist 857.3 Test because that cyclicity 867.4 Test because that overlapping lists-lists room cycle-free 877.5 Test because that overlapping lists-lists may have cycles 887.6 Delete a node from a singly linked list . . 907.7 eliminate the kth last aspect from a list . . 907.8 remove duplicates from a sorted list . . 91,7.9 perform cyclic right change for singly linked lists . 927.1O perform even-odd merge 937.71. Test whether a singly attached list is palindromic 947.12 Implement perform pivoting 957.13 include list-based integers 968 Stacks and Queues 978.1 perform a stack through max API 988.2 evaluate RPN expression 1011t

See more: Can You Use Dreft Stage 1 Vs Stage 2 Dreft Hypoallergenic? Is Stage 2 Dreft Hypoallergenic

Page 9

8.3 check a string end "l,l,(,),1,f" for well-formedness 1,028.4 Normalize pathnames 1028.5 Compute structures with a sunset watch . 1038.6 Compute binary tree nodes in order of boosting depth 1.068.7 perform a one queue 1078.8 perform a queue making use of stacks 1088.9 implement a queue v max API . . 1099 BinaryTrees 1129.1, check if a binary tree is height-balanced 1749.2 check if a binary tree is symmetric 1.769.3 Compute the lowest common ancestor in a binary tree . 1779.4 Compute the LCA once nodes have actually parent needle 1189.5 amount the root-to-leaf courses in a binary tree 1199.6 find a source to leaf route with mentioned sum 1209.7 implement an inorder traversal there is no recursion 1219.8 carry out a preorder traversal there is no recursion 721,9.9 Compute the kth node in one inorder traversal 1229.10 Compute the successor 1239.1,1, carry out an inorder traversal with O(1) space . 1249.12 reconstruct a binary tree native traversal data 1259.13 rebuild a binary tree from a preorder traversal with markers 1279.1,4 form a connected list native the pipeline of a binary tree . 1289.75 Compute the exterior the a binary tree . 1289.1,6 Compute the best sibling tree . 12910 Heaps 13210.1 merge sorted records 13410.2 type an increasing-decreasing array . 13510.3 sort an almost-sorted range 1,3670.4 Compute the k closest stars . L3710.5 Compute the median of digital data . . 13910.6 Compute the k largest aspects in a max-heap 14011 browsing 74211.1 search a sorted range for an initial occurrence ofk 14511.2 find a sorted range for entry equal to its index 1"4611.3 find a cyclically sorted array 1.4711,.4 Compute the integer square source 1,4811.5 Compute the real square root 14911.6 find in a 2D sorted affay . 15077.7 uncover the min and max all at once 75211.8 uncover the kth largest element 15311..9 find the absent IP address 15511.10 discover the duplicate and missing elements 15712 Hash Tables 159111

Page 10

t |J- i rtErrr r l, l12.1. Test because that palindromic permutations 16372.2 Is an cotton letter constructible? 7&12.3 perform an ISBN cache 76512.4 Compute the LCA, optimizing for close ancestors 7661.2.5 find the nearest repetitive entries in variety 1,6712.6 find the smallest subarray extending all values 1,6872.7 discover smallest subarray sequentially spanning all worths 171,72.8 find the longest subarray with unique entries 77312.9 discover the length of a longest had interval 17472.1,0 Compute all string decompositions . 17572.11 check the Collatz conjecture 17612.72 perform a hash function for chess 177L3 Sorting L8013.1 Compute the intersection of 2 sorted arrays 18213.2 Merge 2 sorted arrays 18313.3 remove first-name duplicates 184'13.4 Smallestnonconstructiblevalue 18513.5 Render a calendar 18673.6 merger intervals 18813.7 Compute the union of intervals 18913.8 Partitioning and sorting one affay with numerous rePeated entries 1911.3.9 Team picture day-1 19313.10 lmplement a quick sorting algorithm for lists 79413.11 Compute a value threshold 795L4 Binary search Tiees 19714.'1, check if a binary tree satisfies the BST property . . . . 1,991,4.2 uncover the very first key better than a provided value in a BST 201.1,4.3 uncover the k largest elements in a BST 20214.4 Compute the LCA in a BST 2031,4.5 rebuild a BST native traversal data 20414.6 find the closest entries in three sorted arrays 2061,4.7 Enumerate numbers of the type a + b''12 20714.8 build a minimum height BST native a sorted affay . 2101.4.9 check if three BST nodes are totally ordered 211,14.10 The selection lookup trouble 27214.11 add credits 27515 Recursion 21715.1 The Towers that Hanoi trouble 27975.2 create all nonattacking placements of ,4-Queens 221,15.3 Generatepermutations 2221,5.4 generate the power collection 22415.5 generate all subsets of dimension k . . . . 22615.6 create strings of suitable parens 22715.7 Generatepalindromicdecompositions 2281V