写点什么

ARTS-6

作者:进德修业
  • 2023-09-09
    上海
  • 本文字数:1550 字

    阅读完需:约 5 分钟

ARTS-6

Algorithm 一道算法题


https://leetcode.cn/problems/find-first-and-last-position-of-element-in-sorted-array/

https://leetcode.cn/problems/find-first-and-last-position-of-element-in-sorted-array/solutions/2434675/di-jiu-shi-san-tian-ii-zai-pai-xu-shu-zu-hc8r/


class Solution {    public int[] searchRange(int[] nums, int target) {        //二分查找        int[] result = new int[2];        int index1 = getBinarySearch(nums,target,true);        int index2 = getBinarySearch(nums,target,false);        result[0] = index1;        result[1] = index2;        return result;    }
private int getBinarySearch(int[] nums, int target, boolean flag){ int len = nums.length, left = 0, right = len - 1; int index = -1; while(left <= right){ int mid = (left + right) / 2; if(nums[mid] < target){ left = mid + 1; } else if (nums[mid] == target){ index = mid; break; } else { right = mid - 1; } } //检查是否有重复元素,有的话偏移 //左 while(index != -1 && flag && index > 0){ if(nums[index - 1] == target){ index--; } else { break; } } //右 while(index != -1 && !flag && index < len - 1){ if(nums[index + 1] == target){ index++; } else { break; } } return index; }}
复制代码


Review 读一篇英文文章


https://hackernoon.com/work-from-home-what-works-and-what-doesnt-nqe535au


在家工作:什么有效和什么无效


Work From Home: What Works and What Doesn't


优点


Pros


有机会生活在任何地方


The opportunity to live anywhere


能够独立计划你的一天


The ability to independently plan your day


对于公司来说,这可以大大节省办公室费用


For companies, this is a significant saving on offices


缺点


Cons


孤立和孤独


Isolation and loneliness


身体健康状况恶化 心理健康也会受到影响


Physical health deteriorates mental health also suffers


工作更难了


It's harder to work

如何让远程工作奏效

How to make remote work, work

为自己创造一些很酷的理由离开家


Create cool reasons for yourself to leave the house


设定界限


Set boundaries


避免开会


Avoid meetings


尝试尽可能清晰地制定任务


Try to formulate tasks as clearly as possible


个人总结:远程工作目前只适合少部分人,且不能完全远程,比如说两周面对面一次是更好的。


Personal summary: Remote work is currently only suitable for a small number of people, and it cannot be completely remote. For example, face-to-face work once every two weeks is better.


Technique/Tips 分享一个小技术


Java 类初始化顺序

父静变/父静块/子静变/子静块

父非静变/父非静块/父构

子非静变/子非静块/子构

Java class initialization sequence

parent static variable/parent static block/child static variable/child static block

parent non-static/parent non-static block/parent construct

sub-non-static variable/sub-non-static block/sub-construction


Share 分享一个观点

是我们选择了环境,不是环境选择了我们。


We choose the environment, not the environment chooses us.


发布于: 刚刚阅读数: 4
用户头像

进德修业

关注

还未添加个人签名 2021-05-19 加入

还未添加个人简介

评论

发布
暂无评论
ARTS-6_ARTS 打卡计划_进德修业_InfoQ写作社区