- 博客(31)
- 收藏
- 关注
原创 Palindrome Partitioning II
Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning of s.Example:Input: "aab"Output: 1Explanation: T...
2018-04-28 21:54:46 118
原创 Palindrome Pairs
Given a list of unique words, find all pairs of distinct indices (i, j) in the given list, so that the concatenation of the two words, i.e. words[i] + words[j] is a palindrome.Example 1:Given words = ...
2018-04-27 21:45:22 116
原创 Evaluate Division
Equations are given in the format A / B = k, where A and B are variables represented as strings, and k is a real number (floating point number). Given some queries, return the answers. If the answer d...
2018-04-27 21:16:50 116
原创 K Inverse Pairs Array
Given two integers n and k, find how many different arrays consist of numbers from 1 to n such that there are exactly k inverse pairs.We define an inverse pair as following: For ith and jth element in...
2018-04-27 11:29:33 144
原创 Remove Comments
Given a C++ program, remove comments from it. The program source is an array where source[i] is the i-th line of the source code. This represents the result of splitting the original source code strin...
2018-04-22 21:55:10 260
原创 Preimage Size of Factorial Zeroes Function
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! = 6 has no zeroes at the end, while f(11) = 2 beca...
2018-04-16 22:50:24 140
原创 Patching Array
Given a sorted positive integer array nums and an integer n, add/patch elements to the array such that any number in range [1, n] inclusive can be formed by the sum of some elements in the array. Retu...
2018-04-15 21:57:49 168
原创 Binary Tree Pruning
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 (of the given tree) not containing a 1 has been re...
2018-04-15 21:47:06 239
原创 Prime Number of Set Bits in Binary Representation
Given two integers L and R, find the count of numbers in the range [L, R] (inclusive) having a prime number of set bits in their binary representation.(Recall that the number of set bits an integer ha...
2018-04-15 21:44:01 127
原创 Minimum Swaps To Make Sequences Increasing
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 same index position in their respective sequences.A...
2018-04-15 21:37:56 198
原创 Student Attendance Record II
Given a positive integer n, return the number of all possible attendance records with length n, which will be regarded as rewardable. The answer may be very large, return it after mod 109 + 7.A studen...
2018-04-15 21:26:56 159
原创 K-th Symbol in Grammar
On the first row, we write a de >0de>. Now in every subsequent row, we look at the previous row and replace each occurrence of de >0de> with de >01de>, and each occurrence of de >...
2018-04-10 21:41:15 157
原创 Decode Ways II
A message containing letters from de >A-Zde> is being encoded to numbers using the following mapping way:'A' -> 1'B' -> 2...'Z' -> 26Beyond that, now the encoded string can also con...
2018-04-10 21:40:17 126
原创 Rabbits in Forest
In a forest, each rabbit has some color. Some subset of rabbits (possibly all of them) tell you how many other rabbits have the same color as them. Those de >answersde> are placed in an array.Re...
2018-04-10 21:38:42 143
原创 Distinct Subsequences
Given a string S and a string T, count the number of distinct subsequences of S which equals T.A subsequence of a string is a new string which is formed from the original string by deleting some (can ...
2018-04-10 21:37:53 115
原创 Swap Adjacent in LR String
In a string composed of de >'L'de>, de >'R'de>, and de >'X'de> characters, like de >"RXXLRXRXL"de>, a move consists of either replacing one occurrence of de >"XL"de>
2018-04-10 21:36:58 147
原创 Max Points on a Line
Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.给定一些点的横纵坐标,找出在同一直线上的点的最大数目不会写,抄答案。指定某一个点,计算包含该点的所有直线上有多少个点。具体方法是计算剩下的所有点与该指定点的斜率,斜率相同就认为是在同一直线上,注意以下几...
2018-04-10 21:35:52 141
原创 Minimum ASCII Delete Sum for Two Strings
Given two strings de >s1, s2de>, find the lowest ASCII sum of deleted characters to make two strings equal.Example 1:Input: s1 = "sea", s2 = "eat"Output: 231Explanation: Deleting "s" from "sea...
2018-04-10 21:34:38 64
原创 Largest Divisible Subset
Given a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of elements in this subset satisfies: Si % Sj = 0 or Sj % Si = 0.If there are multiple solutions, retur...
2018-04-10 21:33:24 295
原创 Split Array Largest Sum
Given an array which consists of non-negative integers and an integer m, you can split the array into m non-empty continuous subarrays. Write an algorithm to minimize the largest sum among these m sub...
2018-04-10 21:28:38 178
原创 Edit Distance
Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have the following 3 operations permitted on a word:a) I...
2018-04-08 21:46:51 127
原创 Network Delay Time
There are N network nodes, labelled 1 to N.Given times, a list of travel times as directed edges times[i] = (u, v, w), where u is the source node, vis the target node, and w is the time it takes for a...
2018-04-08 21:40:31 134
原创 Unique Paths
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the bott...
2018-04-08 21:34:55 86
原创 Reorganize String
Given a string S, check if the letters can be rearranged so that two characters that are adjacent to each other are not the same.If possible, output any possible result. If not possible, return the e...
2018-04-03 21:51:47 214
原创 All Paths From Source to Target
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 follows: the nodes are 0, 1, ..., graph.length - 1. g...
2018-04-03 21:46:36 160
翻译 Openswitch移植指南
OPX移植指南1. 初步内容和在制品OPX Base代码被开发为可以移植到各种各样的硬件平台(的形态)。除了SAI和SDI构件之外(含),只要少量的代码是平台特定的(只能支持特定的硬件平台)。大多数的平台特定的功能被定义在配置文件中,这些配置文件在系统初始化时被定位。交换机抽象接口(SAI)和系统设备接口(SDI)组件包含网络处理单元(NPU)和系统设备专用组件。SAI和SDI实现是设备和...
2018-04-02 21:53:25 1508 1
原创 Daily Temperatures
Given a list of daily temperatures, produce a list that, for each day in the input, tells you how many days you would have to wait until a warmer temperature. If there is no future day for which this ...
2018-04-02 21:51:06 71
原创 Max Increase to Keep City Skyline
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 number of buildings, by any amount (the amounts can...
2018-04-02 21:45:40 98
原创 Max Chunks To Make Sorted
Given an array arr that is a permutation of [0, 1, ..., arr.length - 1], we split the array into some number of "chunks" (partitions), and individually sort each chunk. After concatenating them, the ...
2018-04-02 21:41:37 147
原创 Remove Nth Node From End of List
Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the en...
2018-04-02 21:36:23 107
原创 Rotate String
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, if A = 'abcde', then it will be 'bcdea' after one s...
2018-04-02 21:31:10 101
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人