0%

Question

Given a non-empty array of non-negative integers nums, the degree of this array is defined as the maximum frequency of any one of its elements.

Your task is to find the smallest possible length of a (contiguous) subarray of nums, that has the same degree as nums.

Read more »

Question

You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.

You may assume the two numbers do not contain any leading zero, except the number 0 itself.

Example:
Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)
Output: 7 -> 0 -> 8
Explanation: 342 + 465 = 807.

Read more »

最近在休息期间看了《王牌对王牌》,让我彻底改变了对歌手华晨宇(花花)的看法,感觉就是一个聪明、单纯、善良、有才华的大男孩。然后听了他的好几首歌曲,莫名觉得特别好听,突然转粉了。回过头来仔细想想,对偏见与刻板印象有了新的理解,也算是这段时间最大的反思和感悟了。

记得2013年的时候看过几期《快乐男声》,当时不知道为什么对花花印象特别差,认为他是个生活不能自理,台上“发神经”的男孩。其实当时都没有仔细听他唱过几首歌,就是因为镜头上的几个剪辑,对他留下了这种刻板印象,之后就再也没有关注过他。

Read more »

Question

给定一个长度为n的数组,该数组中的每个元素在1到n范围内,要求在O(n)的时间复杂度,O(1)的空间复杂度下,打印1到n这n个数各出现了多少次。

Read more »

Question

Implement int sqrt(int x).

Compute and return the square root of x, where x is guaranteed to be a non-negative integer.

Since the return type is an integer, the decimal digits are truncated and only the integer part of the result is returned.

Example 1:
Input: 4
Output: 2

Read more »

Question

  1. Check If a Word Occurs As a Prefix of Any Word in a Sentence

    Given a sentence that consists of some words separated by a single space, and a searchWord.You have to check if searchWord is a prefix of any word in sentence.

    Return the index of the word in sentence where searchWord is a prefix of this word (1-indexed).

    Read more »

Question

Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.

The above elevation map is represented by array [0,1,0,2,1,0,1,3,2,1,2,1]. In this case, 6 units of rain water (blue section) are being trapped. Thanks Marcos for contributing this image!

Example:
Input: [0,1,0,2,1,0,1,3,2,1,2,1]
Output: 6

Read more »

线程与进程区别:

  1. 进程是资源分配的最小单位,线程是CPU调度的最小单位
  2. 一个进程由一个或多个线程组成
  3. 进程之间相互独立,每个进程都有独立的代码和数据空间,但同一进程下的各个线程之间共享进程的代码和内存空间,每个线程有独立的运行栈和程序计数器
  4. 线程上下文切换比进程上下文切换要快得多
Read more »

反射机制的作用

JAVA反射机制是在运行状态中,对于任意一个类,都能够知道这个类的所有属性和方法;对于任意一个对象,都能够调用它的任意方法和属性,实现了基本的动态性。
有了反射,我们可以做以下事情:

Read more »

红黑树

  1. 节点是红色或黑色。
  2. 根节点是黑色。
  3. 每个叶子节点都是黑色的空节点(NIL节点)。
  4. 每个红色节点的两个子节点都是黑色。(从每个叶子到根的所有路径上不能有两个连续的红色节点)
  5. 从任一节点到其每个叶子的所有路径都包含相同数目的黑色节点。
    插入,变色,左旋转,右旋转
Read more »