随笔分类 - 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
阅读全文
摘要:Basic Calculator I Implement a basic calculator to evaluate a simple expression string. The expression string may contain open ( and closing parenthes
阅读全文
摘要:Given an array of strings, group anagrams together. For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"], Return:
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要:Given two strings S and T, determine if they are both one edit distance apart. 分析:https://segmentfault.com/a/1190000003906621 虽然我们可以用Edit Distance的解法,
阅读全文
摘要:Preorder: 因为是preorder traversal, 我们需要先print root,然后左节点,最后右节点,而且root左边子树一定比右边子树先print出来,所以,我们可以先把当前root的右节点压栈,然后把root的左节点压栈,这样每次从栈里取的时候,可以保证左边节点的root先取
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要:Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; } Populate each next pointer to point to its ne
阅读全文
摘要:Given a string, find the longest substring that contains only two unique characters. For example, given "abcbbbbcccbdddadacb", the longest substring t
阅读全文
摘要: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
阅读全文
摘要:Count the number of prime numbers less than a non-negative number, n
阅读全文

浙公网安备 33010602011771号