随笔分类 - LeetCode
摘要:Given a sorted (in ascending order) integer array nums of n elements and a target value, write a function to search target in nums. If target exists,
阅读全文
摘要:Given an integer array sorted in ascending order, write a function to search target in nums. If target exists, then return its index, otherwise return
阅读全文
摘要:Given the root node of a binary search tree (BST) and a value to be inserted into the tree, insert the value into the BST. Return the root node of the
阅读全文
摘要: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's value equals the given value. Retu
阅读全文
摘要:Design your implementation of the circular double-ended queue (deque). Your implementation should support following operations: MyCircularDeque(k): Co
阅读全文
摘要:Design your implementation of the circular queue. The circular queue is a linear data structure in which the operations are performed based on FIFO (F
阅读全文
摘要:Given an n-ary tree, return the preorder traversal of its nodes' values. For example, given a 3-ary tree: Return its preorder traversal as: [1,3,5,6,2
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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:
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文

浙公网安备 33010602011771号