10 2018 档案
摘要:An image is represented by a 2-D array of integers, each integer representing the pixel value of the image (from 0 to 65535). Given a coordinate (sr,
阅读全文
摘要:Implement a magic directory with buildDict, and search methods. For the method buildDict, you'll be given a list of non-repetitive words to build a di
阅读全文
摘要:Alice and Bob have candy bars of different sizes: A[i] is the size of the i-th bar of candy that Alice has, and B[j] is the size of the j-th bar of ca
阅读全文
摘要:A complete binary tree is a binary tree in which every level, except possibly the last, is completely filled, and all nodes are as far left as possibl
阅读全文
摘要:Return any binary tree that matches the given preorder and postorder traversals. Values in the traversals pre and post are distinct positive integers.
阅读全文
摘要:Given a string S of '(' and ')' parentheses, we add the minimum number of parentheses ( '(' or ')', and in any positions ) so that the resulting paren
阅读全文
摘要:小Q定义了一种数列称为翻转数列:给定整数n和m, 满足n能被2m整除。对于一串连续递增整数数列1, 2, 3, 4..., 每隔m个符号翻转一次, 最初符号为'-';。例如n = 8, m = 2, 数列就是: -1, -2, +3, +4, -5, -6, +7, +8.而n = 4, m = 1
阅读全文
摘要:Given an array A of non-negative integers, half of the integers in A are odd, and half of the integers are even. Sort the array so that whenever A[i]
阅读全文
摘要:Given an n-ary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example, given a 3-ary tree:
阅读全文
摘要:Given a string S, return the "reversed" string where all characters that are not a letter stay in the same place, and all letters reverse their positi
阅读全文
摘要:按序记录每棵树叶子节点。比较是否一致。 前序,中序,后序都可以。 Consider all the leaves of a binary tree. From left to right order, the values of those leaves form a leaf value sequ
阅读全文
摘要:Example 1: Input: ["a","b","c","a","c","c"]Output: 3Explanation: 3 groups ["a","a"], ["b"], ["c","c","c"]Example 2: Input: ["aa","bb","ab","ba&qu
阅读全文
摘要:Given a n-ary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest le
阅读全文
摘要:590. N-ary Tree Postorder Traversal Given an n-ary tree, return the postorder traversal of its nodes' values. For example, given a 3-ary tree: Return
阅读全文
摘要:700. Search in a Binary Search Tree Given the root node of a binary search tree (BST) and a value. You need to find the node in the BST that the node'
阅读全文
摘要:On a 2 dimensional grid with R rows and C columns, we start at (r0, c0) facing east. Here, the north-west corner of the grid is at the first row and c
阅读全文
摘要:经典链表题找链表的中间节点 快慢指针 #include #include #include using namespace std; //Definition for singly-linked list. //Given a non-empty, singly linked list with head node head, return a middle node of linked li...
阅读全文
摘要:答案: max(max(A)-min(A)-2*K,0) 代码:
阅读全文
摘要:最小窗口字串 参考 https://www.cnblogs.com/grandyang/p/4340948.html 可以用数组代替hashmap //unordered_map<char,int> letterCnt;vector letterCnt(256,0);
阅读全文
摘要:经典题目:给定一个二叉搜索树,插入一个值为val的新节点
阅读全文
摘要:列出所有可能的完全二叉树
阅读全文
摘要:python解法
阅读全文
摘要:A zero-indexed array A of length N contains all integers from 0 to N-1. Find and return the longest length of set S, where S[i] = {A[i], A[A[i]], A[A[
阅读全文
摘要:对于矩阵A(M*N) 行是否翻转。每一行的第一个数必须为1,因为它的相当于2^(N-1) 列是否翻转。 参考 https://leetcode.com/problems/score-after-flipping-matrix/discuss/143722/C++JavaPython-Easy-and
阅读全文
摘要:将数组排序 奇数在前 偶数在后 用快速排序中的partition算法
阅读全文
摘要:按字典顺序输出1-n 迭代解法
阅读全文
摘要:class Solution { public: int findLHS(vector& nums) { int res=0; map m; for(auto num:nums) ++m[num]; for(auto a:m){ if (m.count(a.first+1)){ ...
阅读全文

浙公网安备 33010602011771号