Harry He
About
Harry He's posts
Post has attachment
Public
How Kubernetes scheduler prioritizes nodes on resources?﻿
Post has attachment
Public
No. 59 - Duplications in Arrays
Questions : All numbers in an array with length n +1 are in range from 1 to n , so there is at least one duplication in the
array. How to find any a duplication? Please don't modify the input array. Analysis : The simple solution is to utilize
hash tables. ...﻿
Post has attachment
Public
No. 58 - Search in Adjacent Numbers
Question : Given an
array where two neighboring elements are adjacent (in absolute difference 1),
can you write an algorithm to search an element in the array and return its
position? If the element appears multiple times, please return the first
occurrence...﻿
Post has attachment
Public
No. 57 - Integer Identical to Index
Problem: Integers in
an array are unique and increasingly sorted. Please write a function/method to
find an integer from array who equals to its index. For example, in the array
{-3, -1, 1, 3, 5}, the number 3 equals its index 3. Analysis: If we scan
all in...﻿
Post has attachment
Public
No. 56 - Maximal Value of Gifts
Question :
A board has n * m cells, and there is a gift with some value (value is greater than
0) in every cell. You can get gifts starting from the top-left cell, and move
right or down in each step, and finally reach the cell at the bottom-right
cell. Wha...﻿
Post has attachment
Public
No. 55 - Translating Numbers to String
Question: Given a
number, please translate it to a string, following the rules: 1 is translated
to 'a', 2 to 'b', …, 12 to 'l', …, 26 to 'z'. For example, the number 12258 can
be translated to "abbeh", "aveh", "abyh",
"lbeh" and "lyh", so there are 5 differ...﻿
Post has attachment
Public
No. 54 - Merge Ranges
Questions: Given an
array of ranges, please merge the overlapping ones. For example, four ranges
[5, 13], [27, 39], [8, 19], [31, 37] (in blue in the Figure1) are merged into
two ranges, which are [5, 19] and [27, 39] (in green in the Figure 1). Analysis: B...﻿
Post has attachment
Public
08 - Comparison and Type Conversion
There are two
comparison operators in JavaScript. One is ==, and the other is ===. The
difference of these two operators is about type conversion. If two values in
different types are compared with ==, they will be converted into the same type
first and the...﻿
Post has attachment
Public
07 - Arrays
Array Construction Arrays can be
created by invoking the constructor Array:   var array1 = new
Array(); array1[0] =
"a"; array1[1] = 1; array1[2] = true;   console.log(array1);
// ["a", 1, true]   Notice that elements
in an array are not necessary to have t...﻿
Post has attachment
Public
06 - Strings
In JavaScript,
characters are also strings with length 1, as demonstrated below: var character = 'a'; var string =
"abcdefg"; console.log(typeof(character));
// string console.log(typeof(string));
// string A string can be
inside both single and double quot...﻿
Wait while more posts are being loaded