第六周的 ARTS,继续加油。

Algorithm

Remove Element

Given an array nums and a value val, remove all instances of that value in-place and return the new length. Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory. The order of elements can be changed. It doesn’t matter what you leave beyond the new length.
Example1

Given nums = [3,2,2,3], val = 3,
Your function should return length = 2, with the first two elements of nums being 2.
It doesn't matter what you leave beyond the returned length.

Example2

Given nums = [0,1,2,2,3,0,4,2], val = 2,
Your function should return length = 5, with the first five elements of nums containing 0, 1, 3, 0, and 4.
Note that the order of those five elements can be arbitrary.
It doesn't matter what values are set beyond the returned length.

解法1

class Solution {
    public int removeElement(int[] nums, int val) {
        if (nums.length == 0) {
            return 0;
        }
        int i = 0;
        for (int j = 0; j < nums.length; j++) {
            if (nums[j] != val) {
                nums[i] = nums[j];
                i++;
            }
        }
        return i;
    }
}

Review

How to Spend The First Hour of Your Work Day on High-Value Tasks

文中给出了如何高效利用一天中第一个小时的建议。

  • 高效的早晨从早起开始
  • 不要在第一个小时做该天的计划,不要把精力最旺盛的时刻花在做计划上了
  • 先完成最不舒适的任务,会让你接下来更轻松
  • 在前一天晚上,前一周做好后续计划
  • 给任务确定花费的时间,这样可以更好的做计划

Tip

Class 类

虚拟机为每个类型管理一个 Class 对象,一个 Class 对象表示一个特定类的属性,它的 getName 方法,将返回类的名字。

Date d = new Date();
Class cl = d.getClass();
String name = cl.getName();

Share

创新

####创新的三大障碍

  • 看不到自己
  • 没问题综合症,欺骗自己,以为早就知道所有问题的答案
  • 唯一办法信念,看不见其他办法 ####提升创新能力
  • 任何问题都存在不止一个办法
  • 创造性错误
  • 偷来的想法
  • 多个想法综合