随笔分类 - Daily Coding Problem
1
摘要:Given an array of words and a width maxWidth, format the text such that each line has exactly maxWidth characters and is fully (left and right) justif
阅读全文
摘要:Given a linear equation of n variables, find the total number of non-negative integer solutions of it. All coefficients are positive. Example: input:
阅读全文
摘要:You are given a series of arithmetic equations as a string, such as: y = x + 1 5 = x + 3 10 = z + y + 2 The equations use addition only and are separa
阅读全文
摘要:A quack is a data structure combining properties of both stacks and queues. It can be viewed as a list of elements written left to right such that thr
阅读全文
摘要:A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down). Write a function to count the total strobog
阅读全文
摘要:A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down). Find all strobogrammatic numbers that are o
阅读全文
摘要:You are given a string consisting of the letters x and y, such as xyxxxyxyy. In addition, you have an operation called flip, which changes a single x
阅读全文
摘要:You have N stones in a row, and would like to create from them a pyramid. This pyramid should be constructed such that the height of each stone increa
阅读全文
摘要:A competitive runner would like to create a route that starts and ends at his house, with the condition that the route goes entirely uphill at first,
阅读全文
摘要:On a mysterious island there are creatures known as Quxes which come in three colors: red, green, and blue. One power of the Qux is that if two of the
阅读全文
摘要:A cryptarithmetic puzzle is a mathematical game where the digits of some numbers are represented by letters. Each letter represents a unique digit. Fo
阅读全文
摘要:Typically, an implementation of in-order traversal of a binary tree has O(h) space complexity, where h is the height of the tree. Write a program to c
阅读全文
摘要:Given a sorted array of non-negative integers, find the smallest positive integer that is not the sum of a subset of the array. For example, for the i
阅读全文
摘要:This problem was asked by Google. In a directed graph, each node is assigned an uppercase letter. We define a path's value as the number of most frequ
阅读全文
摘要:This problem was asked by Microsoft. A number is considered perfect if its digits sum up to exactly 10. Given a positive integer n, return the n-th pe
阅读全文
摘要:This problem was asked by Google. On our special chessboard, two bishops attack each other if they share the same diagonal. This includes bishops that
阅读全文
摘要:This problem was recently asked by Google. Given a list of numbers and a number k, return whether any two numbers from the list add up to k. For examp
阅读全文
摘要:Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k num
阅读全文
摘要:This problem was asked by Google. Implement locking in a binary tree. A binary tree node can be locked or unlocked only if all of its descendants or a
阅读全文
摘要:This problem was asked by Twitter. You run an e-commerce website and want to record the last N order ids in a log. Implement a data structure to accom
阅读全文
1