随笔分类 -  leetcode

摘要:There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every second bulb. On the third round, you toggle every 阅读全文
posted @ 2018-11-02 21:33 hopskin1 阅读(154) 评论(0) 推荐(0)
摘要:In English, we have a concept called root, which can be followed by some other words to form another longer word - let's call this word successor. For 阅读全文
posted @ 2018-11-02 21:13 hopskin1 阅读(202) 评论(0) 推荐(0)
摘要: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, 阅读全文
posted @ 2018-10-26 23:22 hopskin1 阅读(227) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2018-10-26 22:47 hopskin1 阅读(156) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2018-10-25 07:50 hopskin1 阅读(199) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2018-10-25 07:27 hopskin1 阅读(289) 评论(0) 推荐(0)
摘要:Return any binary tree that matches the given preorder and postorder traversals. Values in the traversals pre and post are distinct positive integers. 阅读全文
posted @ 2018-10-25 06:21 hopskin1 阅读(349) 评论(0) 推荐(0)
摘要:Given a string S of '(' and ')' parentheses, we add the minimum number of parentheses ( '(' or ')', and in any positions ) so that the resulting paren 阅读全文
posted @ 2018-10-24 22:49 hopskin1 阅读(323) 评论(0) 推荐(0)
摘要: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]  阅读全文
posted @ 2018-10-14 21:29 hopskin1 阅读(525) 评论(0) 推荐(1)
摘要: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: 阅读全文
posted @ 2018-10-14 20:50 hopskin1 阅读(155) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2018-10-14 20:26 hopskin1 阅读(153) 评论(0) 推荐(0)
摘要:按序记录每棵树叶子节点。比较是否一致。 前序,中序,后序都可以。 Consider all the leaves of a binary tree. From left to right order, the values of those leaves form a leaf value sequ 阅读全文
posted @ 2018-10-14 20:04 hopskin1 阅读(224) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2018-10-14 19:43 hopskin1 阅读(313) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2018-10-14 19:17 hopskin1 阅读(166) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2018-10-10 01:27 hopskin1 阅读(169) 评论(0) 推荐(0)
摘要: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' 阅读全文
posted @ 2018-10-10 01:21 hopskin1 阅读(126) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2018-10-10 01:04 hopskin1 阅读(184) 评论(0) 推荐(0)
摘要:经典链表题找链表的中间节点 快慢指针 #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... 阅读全文
posted @ 2018-10-09 23:40 hopskin1 阅读(142) 评论(0) 推荐(0)
摘要:答案: max(max(A)-min(A)-2*K,0) 代码: 阅读全文
posted @ 2018-10-09 08:03 hopskin1 阅读(98) 评论(0) 推荐(0)
摘要:代码 阅读全文
posted @ 2018-10-09 00:28 hopskin1 阅读(138) 评论(0) 推荐(0)