摘要:
Given an n-ary tree, return the postorder traversal of its nodes' values. For example, given a 3-ary tree: Return its postorder traversal as: [5,6,3,2
阅读全文
posted @ 2018-10-31 10:11
Grandyang
阅读(2497)
推荐(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-29 21:41
Grandyang
阅读(3532)
推荐(0)
摘要:
A quadtree is a tree data in which each internal node has exactly four children: topLeft, topRight, bottomLeft and bottomRight. Quad trees are often u
阅读全文
posted @ 2018-10-24 23:44
Grandyang
阅读(2101)
推荐(0)
摘要:
在3D Slicer中,我们如果想在自己写的插件中来修改三维视图中的默认设置的话,那么首先就需要获得三维视图的结点,其类型为vtkMRMLViewNode,获得了这个结点后,我们就可以用代码来修改一系列属性了,比如隐藏方框和坐标轴标签等。这里我们通过使用系统函数getNode()来获得三维视图节点,
阅读全文
posted @ 2018-10-19 04:06
Grandyang
阅读(819)
推荐(0)
摘要:
Given an array w of positive integers, where w[i] describes the weight of index i, write a function pickIndex which randomly picks an index in proport
阅读全文
posted @ 2018-10-13 23:05
Grandyang
阅读(13202)
推荐(1)
摘要:
You are given the number of rows n_rows and number of columns n_cols of a 2D binary matrix where all values are initially 0. Write a function flip whi
阅读全文
posted @ 2018-10-12 23:32
Grandyang
阅读(3435)
推荐(0)
摘要:
Given a list of non-overlapping axis-aligned rectangles rects, write a function pick which randomly and uniformily picks an integer point in the space
阅读全文
posted @ 2018-10-07 23:54
Grandyang
阅读(4245)
推荐(0)
摘要:
Given the radius and x-y positions of the center of a circle, write a function randPoint which generates a uniform random point in the circle. Note: E
阅读全文
posted @ 2018-10-03 23:09
Grandyang
阅读(4215)
推荐(0)
摘要:
Given a function rand7 which generates a uniform random integer in the range 1 to 7, write a function rand10 which generates a uniform random integer
阅读全文
posted @ 2018-09-30 00:00
Grandyang
阅读(7360)
推荐(1)
摘要:
You are given a doubly linked list which in addition to the next and previous pointers, it could have a child pointer, which may or may not point to a
阅读全文
posted @ 2018-09-21 21:24
Grandyang
阅读(6186)
推荐(0)
摘要:
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-09-18 23:59
Grandyang
阅读(3672)
推荐(0)
摘要:
We want to use quad trees to store an N x N boolean grid. Each cell in the grid can only be true or false. The root node represents the whole grid. Fo
阅读全文
posted @ 2018-09-14 22:46
Grandyang
阅读(5461)
推荐(0)
摘要:
Convert a BST to a sorted circular doubly-linked list in-place. Think of the left and right pointers as synonymous to the previous and next pointers i
阅读全文
posted @ 2018-09-09 23:34
Grandyang
阅读(11310)
推荐(1)
摘要:
You are given the head of a linked list containing unique integer values and an integer array nums that is a subset of the linked list values. Return
阅读全文
posted @ 2018-09-06 21:56
Grandyang
阅读(6539)
推荐(1)
摘要:
We had some 2-dimensional coordinates, like "(1, 3)" or "(2, 0.5)". Then, we removed all commas, decimal points, and spaces, and ended up with the str
阅读全文
posted @ 2018-08-30 23:56
Grandyang
阅读(2798)
推荐(1)
摘要:
We are given the head node root of a binary tree, where additionally every node's value is either a 0 or a 1. Return the same tree where every subtree
阅读全文
posted @ 2018-08-26 23:45
Grandyang
阅读(3853)
推荐(1)
摘要:
We partition a row of numbers A into at most K adjacent (non-empty) groups, then our score is the sum of the average of each group. What is the larges
阅读全文
posted @ 2018-08-20 11:05
Grandyang
阅读(4779)
推荐(0)
摘要:
A website domain like "discuss.leetcode.com" consists of various subdomains. At the top level, we have "com", at the next level, we have "leetcode.com
阅读全文
posted @ 2018-08-16 11:01
Grandyang
阅读(3160)
推荐(0)
摘要:
You have a list of points in the plane. Return the area of the largest triangle that can be formed by any 3 of the points. Notes: 3 <= points.length <
阅读全文
posted @ 2018-08-11 23:00
Grandyang
阅读(3595)
推荐(0)
摘要:
We are given non-negative integers nums[i] which are written on a chalkboard. Alice and Bob take turns erasing exactly one number from the chalkboard,
阅读全文
posted @ 2018-08-08 21:58
Grandyang
阅读(2312)
推荐(0)
摘要:
Sometimes people repeat letters to represent extra feeling, such as "hello" -> "heeellooo", "hi" -> "hiiii". Here, we have groups, of adjacent letters
阅读全文
posted @ 2018-08-05 20:03
Grandyang
阅读(4746)
推荐(1)
摘要:
There are two types of soup: type A and type B. Initially we have N ml of each type of soup. There are four kinds of operations: Serve 100 ml of soup
阅读全文
posted @ 2018-08-02 12:21
Grandyang
阅读(2983)
推荐(0)
摘要:
In a 2 dimensional array grid, each value grid[i][j] represents the height of a building located there. We are allowed to increase the height of any n
阅读全文
posted @ 2018-07-28 21:21
Grandyang
阅读(7197)
推荐(0)
摘要:
We have a grid of 1s and 0s; the 1s in a cell represent bricks. A brick will not drop if and only if it is directly connected to the top of the grid,
阅读全文
posted @ 2018-07-24 21:36
Grandyang
阅读(4880)
推荐(0)
摘要:
We are to write the letters of a given string S, from left to right into lines. Each line has maximum width 100 units, and if writing a letter would c
阅读全文
posted @ 2018-07-21 23:51
Grandyang
阅读(3345)
推荐(0)
摘要:
International Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes, as follows: "a" maps to ".-", "b" map
阅读全文
posted @ 2018-07-19 23:04
Grandyang
阅读(3668)
推荐(0)
摘要:
We start at some node in a directed graph, and every turn, we walk along a directed edge of the graph. If we reach a terminal node (that is, it has no
阅读全文
posted @ 2018-07-16 20:36
Grandyang
阅读(5096)
推荐(0)
摘要:
We have two integer sequences A and B of the same non-zero length. We are allowed to swap elements A[i] and B[i]. Note that both elements are in the s
阅读全文
posted @ 2018-07-14 23:56
Grandyang
阅读(6052)
推荐(0)
摘要:
In the following, every capital letter represents some hexadecimal digit from 0 to f. The red-green-blue color "#AABBCC" can be written as "#ABC" in s
阅读全文
posted @ 2018-07-11 20:46
Grandyang
阅读(4873)
推荐(0)
摘要:
We stack glasses in a pyramid, where the first row has 1 glass, the second row has 2 glasses, and so on until the 100th row. Each glass holds one cup
阅读全文
posted @ 2018-07-09 22:44
Grandyang
阅读(3923)
推荐(0)
摘要:
Given an array A, we may rotate it by a non-negative integer K so that the array becomes A[K], A[K+1], A{K+2], ... A[A.length - 1], A[0], A[1], ..., A
阅读全文
posted @ 2018-07-06 12:13
Grandyang
阅读(3389)
推荐(1)
摘要:
Given a directed, acyclic graph of N nodes. Find all possible paths from node 0 to node N-1, and return them in any order. The graph is given as follo
阅读全文
posted @ 2018-07-04 10:45
Grandyang
阅读(4752)
推荐(0)
摘要:
We are given two strings, A and B. A shift on A consists of taking string A and moving the leftmost character to the rightmost position. For example,
阅读全文
posted @ 2018-07-01 22:13
Grandyang
阅读(5103)
推荐(0)
摘要:
We are given an array A of positive integers, and two positive integers L and R (L <= R). Return the number of (contiguous, non-empty) subarrays such
阅读全文
posted @ 2018-06-28 11:47
Grandyang
阅读(3541)
推荐(1)
摘要:
A Tic-Tac-Toe board is given as a string array board. Return True if and only if it is possible to reach this board position during the course of a va
阅读全文
posted @ 2018-06-25 10:21
Grandyang
阅读(5165)
推荐(1)
摘要:
Let f(x) be the number of zeroes at the end of x!. (Recall that x! = 1 * 2 * 3 * ... * x, and by convention, 0! = 1.) For example, f(3) = 0 because 3!
阅读全文
posted @ 2018-06-22 16:15
Grandyang
阅读(2975)
推荐(1)
摘要:
Given a string s and an array of strings words, return the number of words[i] that is a subsequence of s. A subsequence of a string is a new string ge
阅读全文
posted @ 2018-06-19 21:53
Grandyang
阅读(7015)
推荐(0)
摘要:
S and T are strings composed of lowercase letters. In S, no letter occurs more than once. S was sorted in some custom order previously. We want to per
阅读全文
posted @ 2018-06-16 11:13
Grandyang
阅读(7832)
推荐(0)
摘要:
You have two types of tiles: a 2 x 1 domino shape and a tromino shape. You may rotate these shapes. Given an integer n, return the number of ways to t
阅读全文
posted @ 2018-06-13 19:58
Grandyang
阅读(6004)
推荐(0)
摘要:
You are playing a simplified Pacman game. You start at the point (0, 0), and your destination is (target[0], target[1]). There are several ghosts on t
阅读全文
posted @ 2018-06-11 08:00
Grandyang
阅读(2948)
推荐(0)