查看: 23611| 回复: 39
跳转到指定楼层
上一主题 下一主题
收起左侧

西雅图打卡

全局:

注册一亩三分地论坛,查看更多干货!

您需要 登录 才可以下载或查看附件。没有帐号?注册账号

x
本人uw研究生,为找工作刷题打卡。

上一篇:在职刷题记录打卡
下一篇:在职跳槽 leetcode 记录贴
推荐
 楼主| deepforce 2019-11-6 16:48:47 | 只看该作者
全局:
上周的Contest
1247. Minimum Swaps to Make Strings Equal
Problem: Return the minimum number of swaps required to make s1 and s2 equal, or return -1 if it is impossible to do so.
Solution: 统计两字符串同一位置(x,y)和(y,x)数目,两个分别除以2后得到至少要交换的次数,再判断%2是否都为1,是则再加2。其余情况都为-1

1248. Count Number of Nice Subarrays
Problem: Given an array of integers nums and an integer k. A subarray is called nice if there are k odd numbers on it.
Return the number of nice sub-arrays.
Solution: sliding window, 统计恰好为K可以变成至多为K减去至多为K-1.
回复

使用道具 举报

推荐
 楼主| deepforce 2019-10-15 09:49:52 | 只看该作者

10/14/2019

全局:
794. Valid Tic-Tac-Toe StateProblem: Return True if and only if it is possible to reach this board position during the course of a valid tic-tac-toe game.
Solution: Ensure 2 things: 1. Number of 'x' equal to number of 'o' or bigger than 1.
                                     2. 1) if 'o' wins, # of 'x' = # of 'o'
                                         2) if 'x' wins, 1 or 2 line(s) with same symbol
                                         3) if no one wins, 0 line with same symbbol
回复

使用道具 举报

推荐
 楼主| deepforce 2019-11-29 22:02:18 | 只看该作者
全局:
1268. Search Suggestions System
Problem: Given an array of strings products and a string searchWord.
Solution: 不用Trie,直接排序后找出当前输入字符串最匹配的那个,连续取三个,亚麻OA好像也出现过的样子

1267. Count Servers that Communicate
Problem: Return the number of servers that communicate with any other server.
Solution: 统计columns和rows是否存在1,(m+n),然后m*n判断为1时行列是否存在1.

1114. Print in Order
Problem: Design a mechanism and modify the program to ensure that second() is executed after first(), and third() is executed after second().
Solution: multithreading, c++用的是condition variable判断和唤醒

1266. Minimum Time Visiting All Points
Problem: Your task is to find the minimum time in seconds to visit all points.
Solution: 可横,竖,斜着走,所以直接判断max(横,竖)
回复

使用道具 举报

🔗
 楼主| deepforce 2019-10-7 06:31:24 | 只看该作者

10/06/2019

全局:
本帖最后由 deepforce 于 2019-10-7 07:10 编辑

269. Alien Dictionary
Problem: Given a list of sorted non-empty words based on new lexicographic, return the order of letters.
Solution: topological sort using BFS.
回复

使用道具 举报

🔗
yangx388 2019-10-7 06:47:56 | 只看该作者
全局:
deepforce 发表于 2019-10-7 06:31
269. Alien Dictionary
Problem: Given a list of sorted non-empty words based on new lexicographic, r ...

UW undergrad路过~
回复

使用道具 举报

🔗
 楼主| deepforce 2019-10-7 07:11:27 | 只看该作者
全局:

哈哈,兄弟加油
回复

使用道具 举报

🔗
 楼主| deepforce 2019-10-7 10:51:25 | 只看该作者
全局:
347. Top K Frequent Elements
Problem: Given a non-empty array of integers, return the k most frequent elements.
Solution: bucket sort, use frequency of each number as index.
回复

使用道具 举报

🔗
 楼主| deepforce 2019-10-7 13:32:51 | 只看该作者
全局:
680. Valid Palindrome II
Problem: Given a non-empty string s, delete at most one character, check if make it a palindrome.
Solution: One pass from both left and right side by finding the different pair. Then ignore one of them and check it again.
回复

使用道具 举报

🔗
 楼主| deepforce 2019-10-8 16:26:50 | 只看该作者

10/08/2019

全局:
本帖最后由 deepforce 于 2019-10-8 16:53 编辑

138. Copy List with Random Pointer
Problem: Return a deep copy of the list that with random pointer.
Solution:
To avoid closed loop, use three time iteration.
first iteration create copy node after each original node.
second iteration add random pointer to each copied node.
third iteration extract each copy node and connect them together.
572. Subtree of Another Tree
Problem: Given two non-empty binary trees s and t, check whether tree t has exactly the same structure and node values with a subtree of s.
Solution: Find the same node first. Set it as root node, then check the structure and value of each node of both tree recursively.


回复

使用道具 举报

🔗
 楼主| deepforce 2019-10-9 11:39:07 | 只看该作者

10/08/2019

全局:
本帖最后由 deepforce 于 2019-10-9 12:29 编辑

240. Search a 2D Matrix II
Problem: Write an efficient algorithm that searches for a value in an m x n matrix.
Solution: Search target from left-bottom/top-right corner.

59. Spiral Matrix II
Problem: Given a positive integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.
Solution: Create n*n matrix, then fill numbers from 1 to n*n using four iterations. (4 directions)
回复

使用道具 举报

🔗
 楼主| deepforce 2019-10-11 12:55:35 | 只看该作者

10/10/2019

全局:
282. Expression Add OperatorsProblem: Given a string that contains only digits 0-9 and a target value, return all possibilities to add binary operators (not unary) +, -, or * between the digits so they evaluate to the target value.
Solution: DFS

这道题很有意思。
回复

使用道具 举报

🔗
 楼主| deepforce 2019-10-11 15:54:46 | 只看该作者

10/11/2019

全局:
158. Read N Characters Given Read4 II - Call multiple times
Problem: Given a file and assume that you can only read the file using a given method read4, implement a method read to read n characters.
Solution: new another char array, size 4


补充内容 (2019-10-17 13:45):
65. Valid Number
Problem: Validate if a given string can be interpreted as a decimal number.
Solution: DFA https://leetcode.com/problems/va ... My-thought-with-DFA
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号
隐私提醒:
  • ☑ 禁止发布广告,拉群,贴个人联系方式:找人请去🔗同学同事飞友,拉群请去🔗拉群结伴,广告请去🔗跳蚤市场,和 🔗租房广告|找室友
  • ☑ 论坛内容在发帖 30 分钟内可以编辑,过后则不能删帖。为防止被骚扰甚至人肉,不要公开留微信等联系方式,如有需求请以论坛私信方式发送。
  • ☑ 干货版块可免费使用 🔗超级匿名:面经(美国面经、中国面经、数科面经、PM面经),抖包袱(美国、中国)和录取汇报、定位选校版
  • ☑ 查阅全站 🔗各种匿名方法

本版积分规则

>
快速回复 返回顶部 返回列表