跟随,学习,进步

Acm

The Ultimate Computer Technology Blog | The Knowledgebase of Computing

https://helloacm.com/
转到作者网站

The Algorithm to Make Words Bold in HTML

Given a set of keywords words and a string S, make all appearances of all keywords in S bold. Any letters between and tags become bold. The returned string should use the least number of tags... [[ This is a content summary only. Visit my website for full links, other content, and more! ]]


The O(N) Increasing Triplet Subsequence Algorithm

Given an unsorted array return whether an increasing subsequence of length 3 exists or not in the array. Formally the function should: Return true if there exists i, j, k such that arr < arr... [[ This is a content summary only. Visit my website for full links, other content, and more! ]]


How to Compute the Greatest Common Divisor of Strings?

For strings S and T, we say “T divides S” if and only if S = T + … + T (T concatenated with itself 1 or more times) Return the largest string X such that X divides str1 and X... [[ This is a content summary only. Visit my website for full links, other content, and more! ]]


Facebook Onsite Interview Preparation Part 3: How to Ace a Design Interview?

The Facebook Onsite Interview will generally consist of three parts: Motivations, and Part 2 Coding/Algorithm, and Part 3 Product Design. This is the Part Three: Design. The so-called Design problems... [[ This is a content summary only. Visit my website for full links, other content, and more! ]]


How to Delete Nodes from Binary Tree and Make a Forest?

Given the root of a binary tree, each node in the tree has a distinct value. After deleting all nodes with a value in to_delete, we are left with a forest (a disjoint union of trees). Return the... [[ This is a content summary only. Visit my website for full links, other content, and more! ]]


Count the Binary Watch Stats using Bruteforce Algorithm via C++ BitSet or Compiler Intrinsics __builtin_popcount

A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom represent the minutes (0-59). Each LED represents a zero or one, with the least significant bit on... [[ This is a content summary only. Visit my website for full links, other content, and more! ]]


How to Design a Tic-Tac-Toe Game?

Design a Tic-tac-toe game that is played between two players on a n x n grid. You may assume the following rules: A move is guaranteed to be valid and is placed on an empty block. Once a winning... [[ This is a content summary only. Visit my website for full links, other content, and more! ]]


The Facebook Initial Coding Interview Experience

Update: I have been careful enough not to leak any confidential information after signing the NDA (non-disclouse agreement) with Facebook. I think, the NDA refers to confidential information such as... [[ This is a content summary only. Visit my website for full links, other content, and more! ]]


Facebook Onsite Interview Preparation Part 2: Coding Questions

The Facebook Onsite Interview will generally consist of three parts: Motivations, and Part 2 Coding, and Part 3 Product Design. This is the Part Two: Coding. At least 2x 45mins interviews where you... [[ This is a content summary only. Visit my website for full links, other content, and more! ]]


The Process Killing Algorithms using Depth First Search or Breadth First Search (Kill a Process)

Given n processes, each process has a unique PID (process id) and its PPID (parent process id). Each process only has one parent process, but may have one or more children processes. This is just... [[ This is a content summary only. Visit my website for full links, other content, and more! ]]


Breadth-First Search Algorithm to Solve Puzzle (Rotting Oranges) in a Grid

In a given grid, each cell can have one of three values: the value 0 representing an empty cell; the value 1 representing a fresh orange; the value 2 representing a rotten orange. Every minute, any... [[ This is a content summary only. Visit my website for full links, other content, and more! ]]


Facebook Onsite Interview Preparation Part 1: Motivation/Bahavior Questions

Congratulations! You have passed the CV screening and the telephone coding assessment of Facebook. Facebook interviews are hard, like other Giants: Google, Amazon, or Microsoft. In Facebook, every... [[ This is a content summary only. Visit my website for full links, other content, and more! ]]


Using Reduce to Count the Array in Javascript

Let’s say, we have an array in Javascript, and we want to group the elements, ount their occurences and store the final results in a key-value dictionary. Input Array: const cars = ; Output... [[ This is a content summary only. Visit my website for full links, other content, and more! ]]


Several Algorithms to Compute the Score of Parentheses

Given a balanced parentheses string S, compute the score of the string based on the following rule: () has score 1 AB has score A + B, where A and B are balanced parentheses strings. (A) has score 2... [[ This is a content summary only. Visit my website for full links, other content, and more! ]]


Two Pointer Algorithm to Find Maximum Two Sum Less Than K

Given an array A of integers and integer K, return the maximum S such that there exists i < j with A + A = S and S < K. If no i, j exist satisfying this equation, return -1. Example 1: Input:... [[ This is a content summary only. Visit my website for full links, other content, and more! ]]


Algorithm to Delete a Character to Make a Valid Palindrome

Given a non-empty string s, you may delete at most one character. Judge whether you can make it a palindrome. Example 1: Input: “aba” Output: True Example 2: Input: “abca”... [[ This is a content summary only. Visit my website for full links, other content, and more! ]]


The Dynamic Programming Algorithm to Compute the Minimum Falling Path Sum

Given a square array of integers A, we want the minimum sum of a falling path through A. A falling path starts at any element in the first row, and chooses one element from each row. The next... [[ This is a content summary only. Visit my website for full links, other content, and more! ]]


Javascript’s toFixed Implementation without Rounding

In Javascript, you can use Number.prototype.toFixed(n) that will return a string version that has n decimal places. For example, (3).toFixed(3) // "3.000" (3.15).toFixed(3) // "3.150" The toFixed... [[ This is a content summary only. Visit my website for full links, other content, and more! ]]


Algorithm to Count the Minimum Add to Make Parentheses Valid

Given a string S of ‘(‘ and ‘)’ parentheses, we add the minimum number of parentheses ( ‘(‘ or ‘)’, and in any positions ) so that the resulting... [[ This is a content summary only. Visit my website for full links, other content, and more! ]]


A Microsoft Coding Interview Screening for Position Principal Software Engineer

A while ago, I was applying a job (Principal Software Engineer) for Microsoft, in Cambridge the Microsoft Research Center. Big IT giants have their own Recruitment teams, and I was contacted by one... [[ This is a content summary only. Visit my website for full links, other content, and more! ]]