美文网首页
亚_麻_OA2

亚_麻_OA2

作者: WinKKKKy | 来源:发表于2019-04-14 07:54 被阅读0次
  1. 找出句子里面最多but not in the word to exclude list
    https://leetcode.com/problems/most-common-word/

  2. count number of substrings with exactly k distinct characters
    一道是用滑动窗口求包含K个distinct字符的子串数目
    https://blog.csdn.net/roufoo/article/details/84934364
    12个test case, 最后一个test case是当k为0时的输出

  3. reOrder log files

  4. find subtree with maximum average node
    https://yeqiuquan.blogspot.com/2017/03/lintcode-597-subtree-with-maximum.html

  5. Highest 5
    highest five, 背景知识是有一堆productID 和product的reviews, 给每一个productID找出最高的五个review的平均值,用priorityqueue做就可以,注意data type是double
    highest five reviews,给一个Map储存的是id和其对应的review score,返回一个Map, key是id,value是相对应的5个最高评分的平均数
    https://yeqiuquan.blogspot.com/2017/03/lintcode-613-high-five.html
    lintcod 第613题类似,区别是amazon的score是double,lintcode是int,注意下就好

  6. find substrings of size k with k-1 distinct characters
    input是inputString和num,output是所有长为num且distinct character为num - 1的subString的list


public List<String> subStringWithKDistinct(String s, int k) {
        Map<Character, Integer> map = new HashMap<>();
        List<String> result = new ArrayList<>();
        int n = s.length();
        if( n * k == 0) {
            return 0;
        } 
        
        int left = 0, right = 0;
        
        while(right < n) {
            map.put(s.charAt(right), right++);
            
            if(map.size() == k) {
                if(right - left == k + 1) {
                    result.add(s.substring(left,right));
                }
            }
            
            if(map.size() > k) {
                int del_idx = Collections.min(map.values());
                map.remove(s.charAt(del_idx));
                left = del_idx + 1;
            }
        }
        
        return result;
        
    }
  1. 有一排数据中心,求最小的cost把所有的数据中心连起来 (MST)
  2. K closest points to origin.
    https://leetcode.com/problems/k-closest-points-to-origin/
  3. 给一个字符串和一个整数k,问有多少个substring有k个distinct character。仔细读题,题目要求的是重复的substring也可以满足要求
    https://leetcode.com/problems/longest-substring-with-at-most-k-distinct-characters/
    https://www.geeksforgeeks.org/count-number-of-substrings-with-exactly-k-distinct-characters/

小土刀

  1. Right Rotation

  2. Grey code

  3. 去元音 remove vowel

  4. 检验括号

  5. longest palindromic substring
    https://leetcode.com/problems/longest-palindromic-substring/

  6. merge two sorted linkedlist

  7. reverse second half of linked list

  8. Subtree

  9. Two Sum

  10. Find K Nearest Point

  11. Overlap Rectangle
    给两个长方形的topLeft和bottomRight坐标, 判断这两个长方形是否重叠
    Rectangle Overlap。这题和leetcode 算相交面积的区别:它帮你定义好两个类,一个叫Point,一个叫Rectangle,Rectangle包括左上右下两个Point, Point包括x, y的值, 这种细节并不影响程序,总之一句判断直接通过了全部20多个case.

  12. window sum

  13. GCD Greatest Common Divisor

  14. LRU Cache count miss

  15. Round Robin

  16. Rotate Matrix

  17. insert into cycle linked list

  18. Loop in linked list

  19. Shorted job first
    一个处理器要处理一堆request,一次只能处理一条,如果它有几个积压着的requests,它会先执行持续时间短的那个;对于持续时间相等的requests,先执行最早到达处理器的request。问平均每个request要等多久才能被处理。input:requestTimes[],每个request到达处理器的时间; durations[] 每个request要处理的持续时间。 两个数组是一一对应的,并已按requestTimes[] 从小到大排序过

  20. Binary search tree minimum sum from root to leaf

  21. Day change(cell growth)
    https://leetcode.com/problems/prison-cells-after-n-days/

  22. Maze
    https://leetcode.com/problems/the-maze/

to 9

public int shortestDistance(int[][] maze, int[] start, int[] dest) {
        int[][] distance = new int[maze.length][maze[0].length];
        for (int[] row: distance)
            Arrays.fill(row, Integer.MAX_VALUE);
        distance[start[0]][start[1]] = 0;
         int[][] dirs={{0, 1} ,{0, -1}, {-1, 0}, {1, 0}};
        Queue < int[] > queue = new LinkedList < > ();
        queue.add(start);
        while (!queue.isEmpty()) {
            int[] s = queue.remove();
            for (int[] dir: dirs) {
                int x = s[0] + dir[0];
                int y = s[1] + dir[1];
                int count = 0;
                while (x >= 0 && y >= 0 && x < maze.length && y < maze[0].length && maze[x][y] == 0) {
                    x += dir[0];
                    y += dir[1];
                    count++;
                }
                if (distance[s[0]][s[1]] + count < distance[x - dir[0]][y - dir[1]]) {
                    distance[x - dir[0]][y - dir[1]] = distance[s[0]][s[1]] + count;
                    queue.add(new int[] {x - dir[0], y - dir[1]});
                }
            }
        }
        return distance[dest[0]][dest[1]] == Integer.MAX_VALUE ? -1 : distance[dest[0]][dest[1]];
    }

  1. Minimum Path Sum 窗口内最小
  2. Four Integer 四个数字 差的绝对值最大
  3. Arithmetic sequence
    https://leetcode.com/problems/arithmetic-slices/
  4. Tree Amplitude
    Given a tree of N nodes, return the amplitude of the tree
    就是从 root 到 leaf max - min 的差
  5. Maximum Minimum Path
    给一个int[][]的matirx,对于一条从左上到右下的path pi,pi中的最小值是mi,求所有mi中的最大值。只能往下或右.
  6. Search in 2D matrix
  7. two close capacity

相关文章

  • 亚_麻_OA2

    找出句子里面最多but not in the word to exclude listhttps://leetco...

  • 《吉祥三宝》周末连环画~温暖的秋冬

    20191101 周末早上,让麻麻多睡会,咪亚咪娜:“我们乖乖陪着” 麻麻起床整理床铺,咪亚咪娜:“我们乖乖晒太阳...

  • 每日声优视频精选(5月1日)

    声优节目推荐连载第三回~今天的精选节目如下: 1、小泽亚李・长绳麻理亚的ozanari #56 出演声优:长绳麻理...

  • 随笔

    哈哈,麻麻投降,美得不止是宝贝的美食,更更更重要的是宝贝的心意。到了三亚,宝贝就没时间给麻麻做了。好纠结,又期待又...

  • 《蒙台梭利儿童教育手册》摘录及心得

    《Dr Montessori’s Own Handbook》玛丽亚·蒙台梭利 作为一个准麻麻,先把这本书我认为将来...

  • 月宫仙子祈福图

    小细节: 海 上 升 明 月 , 天 涯 共 此 时 。 插画师:亚麦小聚 一个勇敢追梦的80后麻麻

  • 带着麻麻去三亚过母亲节

    跟妈妈到了三亚后,只想让她好好的旅行一下。我亲爱的妈妈,今天你是主角。母亲节快到了,我只想我的妈妈能开开心心的过这...

  • 流水 20160225

    吃了药,觉得好很多。喉咙有点痒。 麻麻粑粑去了宋城,明天才到乌镇~我不去了 昨天买的枕头今天又忘记带回来,幸好亚丽...

  • 亚麻OA2,C++

    一二题:Rectangle Overlap, K Closest Points, Window Sum, Long...

  • 洛奇亚、阿柏怪等神奇宝贝没有mega进化?网友:我来补充

    有些神奇宝贝能进行mega进化,如喷火龙,但多数像皮卡丘一样不能。于是有网友补充。洛奇亚的mega形态 麻麻鳗鱼王...

网友评论

      本文标题:亚_麻_OA2

      本文链接:https://www.haomeiwen.com/subject/bwudwqtx.html