自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(133)
  • 收藏
  • 关注

原创 Pairs of Songs With Total Durations Divisible by 60

In a list of songs, thei-thsong has a duration oftime[i]seconds.Return the number of pairs of songs for which their totalduration in seconds is divisible by60. Formally, we want the number o...

2019-03-18 13:06:07 313

原创 Transform to Chessboard

An N x Nboardcontains only0s and1s. In each move, you can swap any 2 rows with each other, or any 2 columns with each other.What is the minimum number of moves to transform the board into a "che...

2019-03-14 19:00:13 249

原创 Card Flipping Game

On a table areNcards, with a positive integer printed on the front and back of each card (possibly different).We flip any number of cards, and after we choose onecard.If the numberXon the ba...

2019-03-14 16:36:50 238

原创 Construct Binary Search Tree from Preorder Traversal

Return the root node of a binarysearchtree that matches the givenpreordertraversal.(Recall that a binary search treeis a binary tree where for everynode, any descendant ofnode.lefthas a valu...

2019-03-14 16:32:41 245

原创 Reveal Cards In Increasing Order

In a deck of cards, every card has a unique integer. You can order the deck inany order you want.Initially, all the cards start face down (unrevealed) in one deck.Now, you do the following steps...

2019-03-13 16:55:09 115

原创 Find Common Characters

Given an arrayAof strings made only from lowercase letters, return a list of all characters that show up in all strings within the list(including duplicates).For example, if a character occurs 3 ...

2019-03-12 11:00:47 303

原创 Increasing Order Search Tree

Given a tree, rearrange the tree inin-orderso that the leftmost node in the tree is now the root of the tree, and every node has no left child and only 1 right child.Example 1:Input: [5,3,6,2,4,...

2019-03-12 10:58:53 106

原创 Minimum Area Rectangle II

Given a set of points in the xy-plane, determine the minimum area ofanyrectangle formed from these points, with sidesnot necessarily parallelto the x and y axes.If there isn't any rectangle, ret...

2019-03-12 10:55:53 114

原创 Permutation Sequence

The set[1,2,3,...,n]contains a total ofn! unique permutations.By listing and labeling all of the permutations in order, we get the following sequence forn= 3:"123" "132" "213" "231" "312"...

2019-03-11 17:50:05 167

原创 Number of Squareful Arrays

Given an arrayAof non-negative integers, the array issquarefulif for every pair of adjacent elements, their sum is a perfect square.Return the number of permutations of A that are squareful. Tw...

2019-03-11 17:38:19 143

原创 Sum of Even Numbers After Queries

We have an arrayAof integers, and an arrayqueriesof queries.For thei-thqueryval =queries[i][0], index= queries[i][1], we addvaltoA[index]. Then, the answer to thei-th query is the sum ...

2019-03-11 14:50:48 117

原创 Binary Tree Cameras

Given a binary tree, we install cameras on the nodes of the tree.Each camera ata node can monitorits parent, itself, and its immediate children.Calculate the minimum number of cameras needed to...

2019-03-09 10:41:06 155

原创 Available Captures for Rook

On an 8 x 8 chessboard, there is one white rook. There also may be empty squares, white bishops, and black pawns. These are given as characters 'R', '.', 'B', and 'p' respectively. Uppercase charact...

2019-03-09 10:28:56 174

原创 Vertical Order Traversal of a Binary Tree

Given a binary tree, return thevertical ordertraversal of its nodesvalues.For each node at position(X, Y), its left and right children respectivelywill be at positions(X-1, Y-1)and(X+1, Y-1)...

2019-03-08 13:32:23 162

原创 Check If Word Is Valid After Substitutions

We are given that the string"abc"is valid.From any valid stringV, we may splitVinto two piecesXandYsuch thatX + Y(Xconcatenated withY) is equal toV. (XorYmay be empty.) Then,X + "...

2019-03-08 12:42:44 82

原创 Word Subsets

We are given two arraysAandBof words. Each word is a string of lowercase letters.Now, say thatwordbis a subset of wordaif every letter inboccurs ina,including multiplicity. For exampl...

2019-03-07 18:58:46 195

原创 Max Consecutive Ones III

Given an arrayAof 0s and 1s, we may change up toKvalues from 0 to 1.Return the length of the longest (contiguous) subarray that contains only 1s.Example 1:Input: A = [1,1,1,0,0,0,1,1,1,...

2019-03-07 18:53:49 221

原创 Largest Perimeter Triangle

Given an arrayAof positive lengths, return the largest perimeter of a triangle withnon-zero area, formed from 3 of these lengths.If it is impossible to form anytriangle of non-zero area, return...

2019-03-06 11:17:23 91

原创 Array of Doubled Pairs

Given an array of integersAwith even length, returntrueif and only if it is possible to reorder it such thatA[2 * i + 1] = 2 * A[2 * i]for every0 <=i < len(A) / 2.Example 1:Input...

2019-03-06 11:14:00 254

原创 Grid Illumination

On aN x Ngrid of cells, each cell(x, y)with0 <= x < Nand0 <= y < Nhas a lamp.Initially, some number of lamps are on.lamps[i]tells us the location of thei-th lamp that is on....

2019-03-06 11:05:42 140

原创 Insert into a Binary Search Tree

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 BST after the insertion. It is guaranteed that th...

2019-03-05 16:22:13 93

原创 Delete Columns to Make Sorted III

We are given an arrayAofNlowercase letter strings, all of the same length.Now, we may choose any set of deletion indices, and for each string, we delete all the characters in those indices.For...

2019-03-04 11:44:15 99

原创 Range Sum of BST

Given therootnode of a binary search tree, return the sum of values of all nodes with value betweenLandR(inclusive).The binary search tree is guaranteed to have unique values.Example 1:...

2019-03-04 11:31:58 225

原创 Cousins in Binary Tree

In a binary tree, the root node is at depth0, and children of each depthknode are at depthk+1.Two nodes of a binary tree arecousinsif they have the same depth, but havedifferent parents.We ...

2019-03-03 13:51:43 195

原创 Squares of a Sorted Array

Given an array of integersAsorted in non-decreasing order,return an array of the squares of each number,also in sorted non-decreasing order.Example 1:Input: [-4,-1,0,3,10]Output: [0,1,9,1...

2019-03-03 13:45:23 114

原创 Number of Atoms

Given a chemicalformula(given as a string), return the count of each atom.An atomic element always starts with an uppercase character, then zero or more lowercase letters, representing the name....

2019-03-02 11:38:16 233

原创 Unique Email Addresses

Every email consists of a local name and a domain name, separated by the @ sign.For example, [email protected],aliceis the local name, andleetcode.comis the domain name.Besides lowercase l...

2019-03-02 11:33:23 423

原创 Find the Town Judge

In a town, there areNpeople labelled from1toN. There is a rumor that one of these people is secretly the town judge.If thetown judge exists, then:The town judge trusts nobody. Everybody (e...

2019-03-01 11:38:07 303

原创 Binary Search

Given asorted(in ascending order) integer arraynumsofnelements and atargetvalue, write a function to searchtargetinnums. Iftargetexists, then return its index, otherwise return-1.Examp...

2019-03-01 11:34:16 73

原创 Delete Columns to Make Sorted

We are given an arrayAofNlowercase letter strings, all of the same length.Now, we may choose any set of deletion indices, and for each string, we delete all the characters in those indices.For...

2019-02-28 15:15:45 119

原创 3Sum With Multiplicity

Given an integer arrayA, and an integertarget, return the number oftuplesi, j, k such thati < j < kandA[i] + A[j] + A[k] == target.As the answer can be very large, return it modulo10^...

2019-02-28 15:08:58 117

原创 Image Overlap

Two imagesAandBare given, represented asbinary, square matrices of the same size. (A binary matrix has only 0s and 1s as values.)We translate one image however we choose (sliding it left, righ...

2019-02-27 20:37:31 110

原创 Reordered Power of 2

Starting with a positive integerN, we reorder the digits in any order (including the original order) such that the leading digit is not zero.Returntrueif and only if we can do this in a way such ...

2019-02-27 20:31:30 176

原创 Triples with Bitwise AND Equal To Zero

Given an array of integers A, find the number of triples of indices (i, j, k) such that:0 <= i < A.length 0 <= j < A.length 0 <= k < A.length A[i] & A[j] & A[k] == 0, wh...

2019-02-26 14:49:34 125

原创 Fibonacci Number

The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1. That is,F(0) = 0,   F...

2019-02-25 18:57:23 75

原创 Flip Binary Tree To Match Preorder Traversal

Given a binary tree with N nodes, each node has a different value from {1, ..., N}.A node in this binary tree can be flipped by swapping the left child and the right child of that node.Consider th...

2019-02-25 18:54:51 100

原创 Minimize Malware Spread

In a network of nodes, each node i is directly connected to another node j if and only if graph[i][j] = 1.Some nodes initial are initially infected by malware.  Whenever two nodes are directly conne...

2019-02-25 18:45:39 123

原创 Flip Equivalent Binary Trees

For a binary tree T, we can define a flip operation as follows: choose any node, and swap the left and right child subtrees.A binary tree X is flip equivalent to a binary tree Y if and only if we ca...

2019-02-24 15:48:15 234

原创 Burst Balloons

Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by array nums. You are asked to burst all the balloons. If the you burst balloon i you will get nums[le...

2019-02-23 14:47:40 219

原创 Check Completeness of a Binary Tree

Given a binary tree, determine if it is a complete binary tree.Definition of a complete binary tree from Wikipedia:In a complete binary tree every level, except possibly the last, is completely fil...

2019-02-23 14:35:43 100

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除