FACY is a new retail platform which create future shopping experience, it’s build on GCP and utilized some services and tools of GCP, this post is an introduction about those services and tools and how they are cooperate with each other.
Read more...
This is going to be a guide about how to combine Ruby On Rails with rswag. Rswag can generate beautiful API documentation, including a UI to explore and test operations, directly from your rspec integration tests.
Read more...
Shortest Bridge In a given 2D binary array A, there are two islands. (An island is a 4-directionally connected group of 1s not connected to any other 1s.)
Now, we may change 0s to 1s so as to connect the two islands together to form 1 island.
Return the smallest number of 0s that must be flipped. (It is guaranteed that the answer is at least 1.)
Read more...
Find and Replace Pattern You have a list of words and a pattern, and you want to know which words in words matches the pattern.
A word matches the pattern if there exists a permutation of letters p so that after replacing every letter x in the pattern with p(x), we get the desired word.
(Recall that a permutation of letters is a bijection from letters to letters: every letter maps to another letter, and no two letters map to the same letter.)
Return a list of the words in words that match the given pattern.
You may return the answer in any order.
Read more...
New 21 Game (math and 1D-DP) Alice plays the following game, loosely based on the card game “21”.
Alice starts with 0 points, and draws numbers while she has less than K points. During each draw, she gains an integer number of points randomly from the range 1, W, where W is an integer. Each draw is independent and the outcomes have equal probabilities.
Alice stops drawing numbers when she gets K or more points. What is the probability that she has N or less points?
Read more...
In computer science, a disjoint-set data structure (also called a union–find data structure or merge–find set) is a data structure that tracks a set of elements partitioned into a number of disjoint (non-overlapping) subsets. It provides near-constant-time operations (bounded by the inverse Ackermann function) to add new sets, to merge existing sets, and to determine whether elements are in the same set. In addition to many other uses (see the Applications section), disjoint-sets play a key role in Kruskal’s algorithm for finding the minimum spanning tree of a graph.
Read more...
The convex hull of a set of points is defined as the smallest convex polygon. I don’t think it’s wise to bring out convex hull problem in a programmmer interview, but it is a interesting problem involved some brilliant solutions.
Read more...
Image Overlap Two images A and B are given, represented as binary, square matrices of the same size. (A binary matrix has only 0s and 1s as values.)
We translate one image however we choose (sliding it left, right, up, or down any number of units), and place it on top of the other image. After, the overlap of this translation is the number of positions that have a 1 in both images.
(Note also that a translation does not include any kind of rotation.)
What is the largest possible overlap?
Read more...
DFS Word Search II Description:
Given a matrix of lower alphabets and a dictionary. Find all words in the dictionary that can be found in the matrix. A word can start from any position in the matrix and go left/right/up/down to the adjacent position. One character only be used once in one word.
Read more...
Course Schedule II There are a total of n courses you have to take, labeled from 0 to n - 1.
Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a pair: 0,1 Given the total number of courses and a list of prerequisite pairs, return the ordering of courses you should take to finish all courses. There may be multiple correct orders, you just need to return one of them. If it is impossible to finish all courses, return an empty array.
Read more...
Regular Expression Matching Given an input string (s) and a pattern (p), implement regular expression matching with support for ’.’ and ’*‘. ’.’ Matches any single character.
’*’ Matches zero or more of the preceding element.
The matching should cover the entire input string (not partial).
Read more...
Out of interest, I joined in Kaggle a year old and participate in several competitions, but I didn’t reach top 15% until 2 month ago. Here I want to share some tips I have learned from those competitions. I am just a programmer with no acadamic background, so if there is mistake, please contact me. Any advice are greatly appreciated.
Read more...
Unlike linear data structures (Array, Linked List, Queues, Stacks, etc) which have only one logical way to traverse them, trees can be traversed in different ways. Following are the generally used ways for traversing trees.
Read more...
I have used many programming languages at work and personal cases. Here I want to share some of stories about them.
Read more...
official doc Heading level 1 Heading level 2 Line Breaks To create a line break (<br>), end a line with two or more spaces, and then type return. like this.
Read more...
Wavelet analysis is a classic and powerful tool for analyzing signals, but its mathematical theory is quite difficult and complicated. In addition to the formula derivation, wavelet analysis has some small but useful details that could be easily ignored. Here I leave some tips so I can quickly pick up things about wavelet in the future.
Read more...
In C programs, sometimes it is necessary to test the running time of a specific code segment. The following code implements code runtime detection in debug mode by adding the header file “time.h” and macro definition.
Read more...