Cracking the Coding Interview 6th Edition

142db55abf0e6eec31639e9abf7dd7e3?s=47 GDP Labs
August 19, 2019

Cracking the Coding Interview 6th Edition

142db55abf0e6eec31639e9abf7dd7e3?s=128

GDP Labs

August 19, 2019
Tweet

Transcript

  1. 2.

    150+ people WHAT WE DO • Help Sister Companies •

    Incubate Startups • Constantly Learning Founded June 2012 Continuous Learning Hard Work Sharing Software Engineer Product Manager System Engineer UX Designer Data Scientist Data Analyst JKT BDG JOG SBY DPS International & national 99 Competitions 255
  2. 5.

    z Empowering SME* Improving HR * Small and medium enterprises

    Affordable • Simple • Integrated https://catapa.com
  3. 6.
  4. 7.

    CRACKING THE CODING INTERVIEW 6th Edition 185 Programming Questions &

    Solutions Gayle Laakmann McDowell © 2015 by CareerCup 7
  5. 9.

    9 Prepare with real interview questions It's about developing a

    fresh algorithm, not memorizing existing problems
  6. 10.

    OUTLINE 1. The Interview Process 2. Before the Interview 3.

    The Offer and Beyond 4. Technical Questions 5. Interview Questions 10
  7. 12.

    12 At most of the top tech companies, algorithm and

    coding problems form the largest component of the interview process. ••• The Interview Process
  8. 13.

    The Interview Process 1. Analytical skills 2. Coding skills 3.

    Technical knowledge / Computer Science fundamentals 4. Experience 5. Culture fit / Communication skills Assessment of your performance: 13 •••
  9. 14.

    ••• The Interview Process 1. False negatives are acceptable 2.

    Problem-solving skills are valuable 3. Basic data structure and algorithm knowledge is useful 4. Whiteboards let you focus on what matters Why do things this way? 14
  10. 15.

    Frequently asked questions 1. If there's no grading system, how

    are you evaluated? How does an interviewer know what to expect of you? 2. I didn't hear back immediately after my interview. Am I rejected? 3. Can I re-apply to a company after getting rejected? 15
  11. 16.

    Companies Interview •• Overview: 1. Screening interview, typically conducted over

    the phone. 2. On-site interview. 3. After your interview, your interviewers will provide feedback in some form. 4. Most companies get back after about a week with next steps. (offer, rejection, further interviews, or just an update on the process). 16
  12. 20.

    Getting the Right Experience 20 For current students: • Take

    the big project classes • Get an internship • Become lab/teaching assistant • Start something Two big things that companies want to see: that you're smart and that you can code
  13. 21.

    • • • • • • • • Preparation Map

    3 - 12 Months • • 1+ Years 1+ Years - Build project outside of school. - Expand network. - Find internship and take classes with large projects. 3-12 Months - Continue to work on projects. - Create draft of CV. - Make list of prefered companies. - Practice interview questions.
  14. 22.

    • • • • • • • • Preparation Map

    3 - 12 Months • • 1+ Years • 1 - 3 Months 4 Weeks • 1-3 Months - Do mini-projects. - Do mock interviews. - Continue to practice interview questions. 4 Weeks - Review/update CV. - Begin applying to companies. - Do another mock interview and continue to practice questions, writing code on paper.
  15. 23.

    • • • • • • • • Preparation Map

    Day before • • 1 Week 1 Week - Phone interview. - Do a final mock interview. - Continue to practice interview questions. Day before - Continue to practice questions & review your list of mistakes. 3 - 12 Months • • 1+ Years • 1 - 3 Months 4 Weeks •
  16. 24.

    • • • • • • • • Day before

    • • 1 Week 3 - 12 Months • • 1+ Years • 1 - 3 Months 4 Weeks • • Day of After • Preparation Map Day Of - Eat a good breakfast & be on time. - Be confident (not cocky). - Remember to talk out loud. After - Write thank you note to recruiter. - If you haven’t heard from recruiter, check in after one week. - If no offer, ask why and when you can re-apply.
  17. 27.

    Offer Deadlines and Extensions • Usually these deadlines are couple

    days to couple weeks out. • If you're still waiting to hear back from other companies, you can ask for an extension. • Companies will usually try to accommodate this, if possible. 27
  18. 28.

    • It's in your best interest to decline the offer

    on good terms and keep a line of communication open. • When you decline an offer, provide a reason that is non-offensive and inarguable. • But, be honest and be professional! Declining an Offer 28
  19. 29.

    Handling Rejection • Getting rejected is unfortunate, but it doesn't

    mean that you're not a great engineer. • Lots of great engineers do poorly, either because they don't "test well" on these sort of interviewers, or they just had an "off" day. • Companies are often eager to re-interview previously rejected candidate. • You can also ask for feedback from the recruiter. 29
  20. 31.

    On the Job 1. Set a Timeline Five years later,

    are you still in there? 2. Build Strong Relationships At work, establish strong relationships with your manager and teammates. When employees leave, keep in touch with them. 3. Ask for What You Want Be (reasonably) frank about your goals with your manager, like “want to take on more back-end coding projects” 4. Keep Interviewing a. Set a goal of interviewing at least once a year, even if you aren’t actively looking for a new job. b. If you get an offer, you don’t have to take it. It will still build a connection with that company in case you want to join at a later date. 31
  21. 33.

    Complexity (Big O) Big O time is the language and

    metric we use to describe the efficiency of algorithms 33 Not understanding it thoroughly can really hurt you in developing an algorithm
  22. 34.

    Complexity (Analogy) Transfer file to your friend across the country

    • Email? • Plane? Car? Walk? Time complexity • Electronic transfer: O(s) • Airplane transfer: O(1) Note: s - size of the file 34 O(1) O(s)
  23. 35.

    Big O, Big Theta, and Big Omega Prints all the

    values in an array • O (big O): upper bound on the time. O(n), O(n2), O(n3), O(2n) • Ω (big omega): lower bound. Ω(n), Ω(log n), Ω(1) • Θ (big theta): means both O and Ω. That is, an algorithm is Θ(n) if it is both O(n) and Ω(n) Industry's meaning of big O is closer to what academics mean by Θ. Best Case, Worst Case, Expected (Average) Case. 35 Complexity
  24. 36.

    Space Complexity Complexity int pairSumSequence(int n) { int sum =

    0; for (int i = 0; i < n; ++i) { sum += (i + i + 1); } return sum; } Time is not the only thing that matters in an algorithm. We might also care about the amount of memory - or space - required by an algorithm. int sum(int n) { if (n <= 0) { return 0; } return n + sum(n - 1); } 36
  25. 37.

    Complexity Big O allows us to express how the runtime

    scales. • Drop the constants O(2N) becomes O(N) • Drop the Non-Dominant Terms O(N2 + N) becomes O(N2). O(N + log N) becomes O(N). O(5 * 2N + 1000 * N100) becomes O(2N). 37
  26. 38.

    Sample Question Complexity int mod(int a, int b) { if

    (b <= 0) { return -1; } int div = a / b; return a - div * b; } The following code computes a % b. What is its runtime? 38
  27. 39.

    Walking through a problem Technical Questions 39 Pay very close

    attention to any information in the problem description. Listen Debug your example. Is there any way it’s a special case? Is it big enough? Draw an Example Get a brute force solution as soon as possible. Don’t code yet though! Brute Force 1. Conceptual test 2. Unusual or non-standard code 3. Hot spots, like null nodes 4. Small test case. Measure time complexity 5. Special cases and edge cases Test Walk through you brute force with BUD (Bottlenecks, Unnecessary, Duplicated) optimization. Optimize Your goal is to write beautiful code. Modularize your code from the beginning and refactor to clean up anything that isn’t beautiful. Keep talking! Implement
  28. 40.

    Optimize & Solve Technique Technical Questions Look for BUD The

    most common things that an algorithm can waste time doing. Walk through your brute force looking for these things. When you find one of them, focus on getting rid of it. 40
  29. 41.

    Bottlenecks Technical Questions Suppose you have a two-steps algorithm where

    you first sort the array O(n log n) and then find elements with a particular property O(n). Perhaps you could reduce O(n) to O(1), but would it matter? 41
  30. 42.

    Unnecessary work Technical Questions Print all positive integer solutions to

    the equation a3 + b3 = c3 + d3, (1 ≤ a, b, c, d ≤ 1000) n = 1000 for a from 1 to n for b from 1 to n for c from 1 to n for d from 1 to n if a3 + b3 == c3 + d3 print a, b, c, d O(N4) n = 1000 for a from 1 to n for b from 1 to n for c from 1 to n for d from 1 to n if a3 + b3 == c3 + d3 print a, b, c, d break O(N4) n = 1000 for a from 1 to n for b from 1 to n for c from 1 to n d = pow(a3 + b3 - c3, 1/3) if a3 + b3 == c3 + d3 print a, b, c, d O(N3) 42 a3 + b3 - c3 = d3
  31. 43.

    Duplicated work Technical Questions The algorithm operates by essentially iterating

    through all (a, b) pairs and searching all (c, d) pairs to find if there are any matches to that (a, b) pair n = 1000 for c from 1 to n for d from 1 to n result = c3 + d3 append (c, d) to list map[result] for a from 1 to n for b from 1 to n result = a3 + b3 list = map.get(result) for each pair in list print a, b, pair n = 1000 for c from 1 to n for d from 1 to n result = c3 + d3 append (c, d) to list at map[result] for each result, list in map for each pair1 in list for each pair2 in list print pair1, pair2 43
  32. 44.

    Optimize & Solve Technique Technical Questions • Data structure brainstorm

    ◦ Number are randomly generated and stored into an (expanding) array. How would you keep track of the median? 44 ◦ Probably not! Tend not to do very well with accessing and sorting numbers ◦ Maybe, but you already have an array. Could you somehow keep the elements sorted? ◦ This is possible, but how? ◦ A heap is really good at basic ordering and keeping track of max and mins.
  33. 45.

    Optimize & Solve Technique Technical Questions • Do It Yourself

    • Simplify and generalize • Base case and build ◦ Often lead to natural recursive algorithms 45
  34. 46.

    Handling Incorrect Answers 1. Responses to interview questions shouldn't be

    thought of as correct or incorrect. 2. Your performance is evaluated in comparison to other candidates. 3. Many-possibly most-questions are too difficult to expect even a strong candidate to immediately spit out the optimal algorithm. 46
  35. 47.

    When You’ve Heard a Question Before • If you've heard

    a question before, admit this to your interviewer. • Your interviewer is asking you these questions in order to evaluate your problem-solving skills. • Additionally, your interviewer may find it highly dishonest if you don't reveal that you know the question. 47
  36. 51.

    51 1. Arrays and Strings 2. Linked Lists 3. Stacks

    and Queues 4. Tree and Graphs 5. Bit Manipulation 6. Math and Logic Puzzles 7. Object Oriented Design 8. Recursion and Dynamic Programming 9. System Design and Scalability 10. Sorting and Searching 11. Testing 12. C and C++ (Optional) 13. Java (Optional) 14. Databases 15. Threads and Locks 16. Moderate (Optional) 17. Hard (Optional) What you need to know!
  37. 52.

    52 • Hash Tables ◦ Hash table is a data

    structure that maps keys to values for highly efficient lookup • ArrayList ◦ Fixed length • Resizable Arrays ◦ Dynamically resizable • StringBuilder ◦ StringBuilder simply creates a resizable array of the strings A good exercise to practice strings, arrays, and general data structures is to implement your own version of StringBuilder, HashTable and ArrayList. 1. Arrays and Strings (Overview) •••
  38. 53.

    1. Arrays and Strings (Example) ••• 53 Palindrome Permutation: Given

    a string, write a function to check if it is a permutation of a palindrome. A permutation is a rearrangement of letters. The palindrome does not need to be limited to just dictionary words. is a word or phrase that is the same forwards and backwards gigi: ggii, gigi, giig, igig, iggi, iigg
  39. 54.

    1. Arrays and Strings (Solution) ••• 54 boolean isPermutationOfPalindrome(String phrase)

    { int countOdd = 0; int[] table = new int[Character.getNumericValue('z') - Character.getNumericValue('a') + 1]; for (char c : phrase.toCharArray()) { int x = getCharNumber(c); if (x != -1) { table[x]++; if (table[x] % 2 == 1) { countOdd++; } else { countOdd--; } } } return countOdd <= 1; } g 1 1 i 1 2 g 2 1 i 2 0 s 1 1 a 1 2 r 1 3 a 2 2 s 2 1
  40. 55.

    2. Linked Lists (Overview) •••••• 55 Unlike an array, a

    linked list does not provide constant time access to a particular index within the list. This means that if you'd like to find the K-th element in the list, you will need to iterate through K elements. The benefit of a linked list is that you can add and remove items from the beginning of the list in constant time.
  41. 56.

    2. Linked Lists (Overview) •••••• 56 • Single Linked List

    • Double Linked List A good exercise to practice is to implement your own version Linked List (get, insert, delete)
  42. 57.

    2. Linked Lists (Example) •••••• 57 Remove Dups: Write code

    to remove duplicates from an unsorted linked list. 1 5 3 10 1 5 5 10 3 1 5
  43. 58.

    2. Linked Lists (Solution) •••••• 58 void deleteDups(LinkedListNode n) {

    HashSet<Integer> set = new HashSet<Integer>(); LinkedListNode previous = null; while (n != null) { if (set.contains(n.data)) { previous.next = n.next; } else { set.add(n.data); previous = n; } n = n.next; } }
  44. 59.

    2. Linked Lists (Example) 59 Follow Up How would you

    solve this problem if a temporary buffer is not allowed? ••••••
  45. 60.

    2. Linked Lists (Solution) •••••• 60 void deleteDups(LinkedListNode head) {

    LinkedListNode current = head; while (current != null) { /* remove all future nodes that have the same value */ LinkedListNode runner = current; while (runner.next != null) { if (runner.next.data == current.data) { runner.next = runner.next.next; } else { runner = runner.next; } } current = current.next; } }
  46. 61.

    61 Stack / Tumpukan: LIFO (Last in first out) It

    uses the operations: • pop() • push(item) • peek() • isEmpty() 3. Stacks and Queues (Overview) ••••
  47. 62.

    62 Queue / Antrian: FIFO (First in first out) It

    uses the operations: • add(item) • remove() • peek() • isEmpty() 3. Stacks and Queues (Overview) ••••
  48. 63.

    3. Stacks and Queues (Example) 63 Three in one: Describe

    how you could use a single array to implement three stacks? ••••
  49. 64.

    64 1 1 1 2 2 2 3 3 3

    1 1 2 2 3 3 3 3 1 1 2 2 3 3 3 3 3 1 1 2 2 3 3 3 3. Stacks and Queues (Solution) ••••
  50. 65.

    4. Trees and Graphs (Overview) ••••• 65 • Binary Tree

    • Binary Search Tree • Balanced & Unbalanced Tree • Complete Binary Tree • Full Binary Tree • Perfect Binary Tree • Binary Heaps • Tries (Prefix Tree) • Traversal ◦ In-Order ◦ Pre-order ◦ Post-Order
  51. 66.

    4. Trees and Graphs (Overview) ••••• 66 • Represent a

    Graph ◦ Adjacency List ◦ Adjacency Matrices ◦ Edge List • Graph search ◦ Depth-First Search ◦ Breadth-First Search ◦ Bidirectional Search
  52. 67.

    4. Trees and Graphs (Example) ••••• 67 Validate BST: Implement

    a function to check if a binary tree is a binary search tree
  53. 68.

    4. Trees and Graphs (Solution) ••••• 68 10 5 3

    0 15 Min: -∞ Max: +∞ Min: -∞ Max: 5 Min: 5 Max: +∞ Min: 5 Max: 10 Min: 10 Max: +∞
  54. 69.

    4. Trees and Graphs (Solution) ••••• 69 boolean checkBST(TreeNode n)

    { return checkBST(n, null, null); } boolean checkBST(TreeNode n, Integer min, Integer max) { if (n == null) { return true; } if ((min != null && n.data <= min) || (max != null && n.data > max)) { return false; } if (!checkBST(n.left, min, n.data) || !checkBST(n.right, n.data, max)) { return false; } return true; }
  55. 70.

    5. Bit Manipulation (Overview) ••• 70 Operators: • & (AND)

    • | (OR) • ~ (NOT) • ^ (XOR) • >> (SHIFT RIGHT) • << (SHIFT LEFT) 10 AND 6 = 1010 & 0110 = 2 1010 0110 ---- & 0010 = 2
  56. 71.
  57. 72.

    5. Bit Manipulation (Solution) ••• 72 ((n & (n -

    1)) == 0) 1 & 0 = 0 2 & 1 = 0 3 & 2 = 2 4 & 3 = 0 5 & 4 = 4 6 & 5 = 4 7 & 6 = 6 8 & 7 = 0 1000000000 0111111111
  58. 73.

    6. Math and Logic Puzzles (Overview) ••• 73 • Logical

    observation • GCD, LCM • Prime Numbers ◦ Sieve Eratosthenes • Probability ◦ and, P(A and B) = P(B | A) P(A) ◦ or, P(A or B) = P(A) + P(B) - P(A and B) ◦ independence, P(A and B) = P(A) P(B) ◦ mutual exclusivity, P(A or B) = P(A) + P(B)
  59. 74.

    6. Math and Logic Puzzles (Example) ••• 74 Dominos: There

    is an 8x8 chessboard in which two diagonally opposite corners have been cut off. You are given 31 dominos, and a single domino can cover exactly two squares. Can you use the 31 dominos to cover the entire board? Prove your answer.
  60. 76.

    7. Object-Oriented Design (Overview) •••• 76 Object oriented design questions

    require a candidate to sketch out the classes and methods to implement technical problems or real-life objects. You have to create elegant, maintainable object-oriented code. How to approach: 1. Handle ambiguity (Ask questions to clarify) 2. Define the core object like Table, Employee, Host, etc 3. Analyze relationships 4. Investigate actions
  61. 77.

    7. Object-Oriented Design (Overview) •••• 77 • Design Patterns ◦

    Singleton class ◦ Factory method ◦ Abstract factory • Concepts ◦ Object/Class ◦ Inheritance ◦ Interface ◦ Polymorphism • Outputs ◦ Sequence diagram ◦ Class diagram
  62. 78.

    78 Parking Lot: Design a parking lot using object-oriented principles.

    7. Object-Oriented Design (Example) ••••
  63. 79.

    79 • Has multiple levels. Each level has multiple rows

    of spots. • motorcycles, cars, and buses. • motorcycle spots, compact spots, and large spots. • A motorcycle can park in any spot. • A car can park in either a single compact spot or a single large spot. • A bus can park in five large spots that are consecutive and within the same row. It cannot park in small spots. 7. Object-Oriented Design (Solution) ••••
  64. 80.

    8. Recursion and Dynamic Programming (Overview) ••••• 80 • How

    to approach: ◦ Bottom-Up ▪ Solve simple case, like a list with only one element, then solve the problem with two elements, three, and so on. ◦ Top-Down ▪ Divide the problem for case N into subproblems. ◦ Half-and-Half ▪ Divide data set in half, and merge together. • Recursive vs Iterative • Memoization ◦ Example problem: Fibonacci numbers
  65. 81.

    8. Recursion and Dynamic Programming (Example) ••••• 81 Triple Step:

    A child is running up a staircase with n steps and can hop either 1 step, 2 steps, or 3 steps at a time. Implement a method to count how many possible ways the child can run up the stairs.
  66. 82.

    8. Recursion and Dynamic Programming (Solution) ••••• 82 82 Illustration

    n n-1 n-2 n-3 Step Combinations 1 1 2 11, 2 3 111, 12, 21, 3 4 1111 121, 211, 112 31, 22, 13
  67. 83.

    8. Recursion and Dynamic Programming (Solution) ••••• 83 int countWays(int

    n) { if (n < 0) return 0; if (n == 0) return 1; return countWays(n-1) + countWays(n-2) + countWays(n-3); } Works, but not efficient
  68. 84.

    8. Recursion and Dynamic Programming (Overview) ••••• 84 int countWays(int

    n) { int[] memo = new int[n + 1]; Arrays.fill(memo, -1); return countWays(n, memo); } int countWays(int n, int[] memo) { if (n < 0) return 0; if (n == 0) return 1; if (memo[n] > -1) return memo[n]; memo[n] = countWays(n-1, memo) + countWays(n-2, memo) + countWays(n-3, memo); return memo[n]; }
  69. 85.

    85 • Horizontal vs Vertical Scaling Vertical: Increasing resources of

    a specific node (add additional memory) Horizontal: Increasing the number of nodes (add additional server) • Load Balancer • Database Denormalization and NoSQL Denormalization: Adding redundant information NoSQL: Not support joins • Database Partitioning (Sharding) - Vertical, Key-Based, Directory-Based • Caching • Asynchronous Processing & Queues • Networking Metrics (Bandwidth, Throughput, Latency) • MapReduce 9. System Design and Scalability (Overview) •••
  70. 86.

    86 Web Crawler: If you were designing a web crawler,

    how would you avoid getting into infinite loops? 9. System Design and Scalability (Example) •••
  71. 88.

    10. Sorting and Searching (Overview) •••• 88 • Sorting ◦

    Bubble Sort ▪ Runtime: O(N2), memory: O(1) ◦ Selection Sort ▪ Runtime: O(N2), memory: O(1) ◦ Merge Sort ▪ Runtime: O(N log N), memory: Depends ◦ Quick Sort ▪ Runtime: O(N log N), memory: O(log N) ◦ Radix Sort ▪ Runtime O(KxN)
  72. 89.

    10. Sorting and Searching (Overview) •••• 89 • Searching ◦

    Linear Search ▪ Runtime: O(N) ◦ Binary search ▪ Precondition : sorted array ▪ Runtime: O(N log N)
  73. 90.

    10. Sorting and Searching (Example) •••• 90 Sorted Merge: You

    are given two sorted arrays, A and B, where A has a large enough buffer at the end to hold B. Write a method to merge B into A in sorted order. 1 2 3 4 5 6 2 3 4 6
  74. 91.

    10. Sorting and Searching (Solution) •••• 91 void merge(int[] a,

    int[] b, int lastA, int lastB) { int indexA = lastA - 1; // Index of last element in array a int indexB = lastB - 1; // Index of last element in array b int indexMerged = lastB + lastA - 1; // end of merged array while (indexB >= 0) { if (indexA >= 0 && a[indexA] > b[indexB]) { a[indexMerged] = a[indexA]; // copy element indexA--; } else { a[indexMerged] = b[indexB]; // copy element indexB--; } indexMerged--; // move indices } }
  75. 92.

    92 • Big picture understanding ◦ Are you a person

    who understands what the software is really about? • Knowing how the pieces fit together ◦ Do you understand how software works, and how it might fit into a greater ecosystem? • Organization ◦ Do you approach the problem in a structured manner, or do you just spout off anything that comes to your head? • Practicality ◦ Can you actually create reasonable testing plans? 11. Testing (Overview) •••
  76. 93.

    11. Testing (Example) ••• 93 Mistake: Find the mistake(s) in

    the following code: unsigned int i; for (i = 100; i >= 0; --i) printf("%d\n", i);
  77. 94.

    11. Testing (Solution) ••• 94 unsigned int i; for (i

    = 100; i > 0; --i) { printf("%u\n", i); } printf("0\n");
  78. 95.

    14. Databases (Overview) ••• 95 • SQL Syntax and Variations

    ◦ Explicit Join vs Implicit Join • Denormalized vs Normalized Databases • SQL Statements ◦ Join vs Inner Join vs Outer Join ◦ Group By • Small Database Design ◦ Handle ambiguity ◦ Define the core objects ◦ Analyze relationships ◦ Investigate actions • Large Database Design ◦ Denormalize
  79. 96.

    14. Databases (Example) ••• 96 Multiple Apartments: Write a SQL

    query to get a list of tenants who are renting more than one apartment. Apartments AptID int UnitNumber varchar(10) BuildingID int AptTenants TenantID int AptID int Tenants TenantID int TenantName varchar(100)
  80. 97.

    14. Databases (Solution) ••• 97 SELECT TenantName FROM Tenants INNER

    JOIN (SELECT TenantID FROM AptTenants GROUP BY TenantID HAVING count(*) > 1) C ON Tenants.TenantID = C.TenantID
  81. 98.

    98 It is, however, relatively common for interviewers at any

    company to assess your general understanding of threads, particularly your understanding of deadlocks. • Thread vs process • Synchronization methods • Locks • Deadlocks and Deadlock Prevention 15. Threads and Locks (Overview) •••
  82. 99.

    15. Threads and Locks (Example) ••• 99 Thread vs. Process:

    What's the difference between a thread and a process?
  83. 100.

    15. Threads and Locks (Solution) ••• 100 A process can

    be thought of as an instance of a program in execution. A process is an independent entity to which system resources (e.g., CPU time and memory) are allocated. A thread exists within a process and shares the process resources (including its heap space) . A thread is a particular execution path of a process. When one thread modifies a process resource, the change is immediately visible to sibling threads.
  84. 101.

    101 Factorial Zeros: Write an algorithm which computes the number

    of trailing zeros in N factorial (N!). 3! = 6 → 0 trailing zero 6! = 720 → 1 trailing zero 12! = 479001600 → 2 trailing zeros 16. Moderate (Example) ••
  85. 102.

    102 To count the number of zeros, we only need

    to count the pairs of multiples of 5 and 2. There will always be more multiples of 2 than 5, though, so simply counting the number of multiples of 5 is sufficient. 16. Moderate (Solution) ••
  86. 103.

    103 Add Without Plus: Write a function that adds two

    numbers. You must not use + or any arithmetic operators. 17. Hard (Example) ••
  87. 104.

    104 For example to add 759 and 674: 1. Add

    759 + 674, but "forget" to carry. Get 323. 2. Add 759 + 674 but only do the carrying, rather than the addition of each digit. Get 1110. 3. Add the result of the first two operations (recursively, using the same process described in step 1 and 2): 323 + 1110 = 1433 Step 1 can be done using bitwise xor operator. Step 2 can be done using bitwise and operator. Recurse until there's nothing to carry. 17. Hard (Solution) ••
  88. 107.

    107 jobs@gdplabs.id MACHINE LEARNING CLOUD COMPUTING WEB & MOBILE COMPUTING

    INFORMATION SECURITY SCALABLE INFRASTRUCTURE https://career.catapa.com/gdplabs/about APPLY NOW! VISIT →