随笔分类 -  Snapchat

摘要:Given a sorted array, two integers k and x, find the k closest elements to x in the array. The result should also be sorted in ascending order. If the 阅读全文
posted @ 2019-02-19 06:51 北叶青藤 阅读(138) 评论(0) 推荐(0)
摘要:Basic Calculator I Implement a basic calculator to evaluate a simple expression string. The expression string may contain open ( and closing parenthes 阅读全文
posted @ 2019-02-18 02:42 北叶青藤 阅读(373) 评论(0) 推荐(0)
摘要:Given an array of strings, group anagrams together. For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"], Return: 阅读全文
posted @ 2016-12-13 14:58 北叶青藤 阅读(161) 评论(0) 推荐(0)
摘要:Design a data structure that supports all following operations in O(1) time. insert(val): Inserts an item val to the set if not already present.remove 阅读全文
posted @ 2016-12-08 10:51 北叶青藤 阅读(254) 评论(0) 推荐(0)
摘要:Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si < ei), determine if a person could attend all mee 阅读全文
posted @ 2016-12-01 05:55 北叶青藤 阅读(724) 评论(0) 推荐(0)
摘要:A frog is crossing a river. The river is divided into x units and at each unit there may or may not exist a stone. The frog can jump on a stone, but i 阅读全文
posted @ 2016-11-04 22:09 北叶青藤 阅读(452) 评论(0) 推荐(0)
摘要:Given an integer matrix, find the length of the longest increasing path. From each cell, you can either move to four directions: left, right, up or do 阅读全文
posted @ 2016-10-29 06:27 北叶青藤 阅读(244) 评论(0) 推荐(0)
摘要:Given a list of airline tickets represented by pairs of departure and arrival airports [from, to], reconstruct the itinerary in order. All of the tick 阅读全文
posted @ 2016-10-17 09:40 北叶青藤 阅读(269) 评论(0) 推荐(0)
摘要:There are a total of n courses you have to take, labeled from 0 to n - 1. Some courses may have prerequisites, for example to take course 0 you have t 阅读全文
posted @ 2016-10-11 11:48 北叶青藤 阅读(390) 评论(0) 推荐(0)
摘要:According to the Wikipedia's article: "The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John 阅读全文
posted @ 2016-08-08 22:13 北叶青藤 阅读(402) 评论(0) 推荐(0)
摘要:Given a root node reference of a BST and a key, delete the node with the given key in the BST. Return the root node reference (possibly updated) of th 阅读全文
posted @ 2016-08-07 05:21 北叶青藤 阅读(283) 评论(0) 推荐(0)
摘要:Given two strings S and T, determine if they are both one edit distance apart. 分析:https://segmentfault.com/a/1190000003906621 虽然我们可以用Edit Distance的解法, 阅读全文
posted @ 2016-08-06 12:42 北叶青藤 阅读(279) 评论(0) 推荐(0)
摘要:Preorder: 因为是preorder traversal, 我们需要先print root,然后左节点,最后右节点,而且root左边子树一定比右边子树先print出来,所以,我们可以先把当前root的右节点压栈,然后把root的左节点压栈,这样每次从栈里取的时候,可以保证左边节点的root先取 阅读全文
posted @ 2016-08-06 02:47 北叶青藤 阅读(337) 评论(0) 推荐(0)
摘要:Given an array of words and a length L, format the text such that each line has exactly L characters and is fully (left and right) justified. You shou 阅读全文
posted @ 2016-08-06 01:47 北叶青藤 阅读(190) 评论(0) 推荐(0)
摘要:A group of two or more people wants to meet and minimize the total travel distance. You are given a 2D grid of values 0 or 1, where each 1 marks the h 阅读全文
posted @ 2016-08-05 00:34 北叶青藤 阅读(262) 评论(0) 推荐(0)
摘要:Given two sparse matrices A and B, return the result of AB. You may assume that A's column number is equal to B's row number. Example: A = [ [ 1, 0, 0 阅读全文
posted @ 2016-08-04 05:39 北叶青藤 阅读(174) 评论(0) 推荐(0)
摘要:Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; } Populate each next pointer to point to its ne 阅读全文
posted @ 2016-08-03 02:31 北叶青藤 阅读(287) 评论(0) 推荐(0)
摘要:Given a string, find the longest substring that contains only two unique characters. For example, given "abcbbbbcccbdddadacb", the longest substring t 阅读全文
posted @ 2016-08-03 01:05 北叶青藤 阅读(304) 评论(0) 推荐(0)
摘要:Nested List Weight Sum I Given a nested list of integers, return the sum of all integers in the list weighted by their depth. Each element is either a 阅读全文
posted @ 2016-08-01 02:55 北叶青藤 阅读(327) 评论(0) 推荐(0)
摘要:Count the number of prime numbers less than a non-negative number, n 阅读全文
posted @ 2016-07-31 11:27 北叶青藤 阅读(177) 评论(0) 推荐(0)