leetcode441
题目要求
1 | You have a total of n coins that you want to form in a staircase shape, where every k-th row must have exactly k coins. |
用n个硬币搭台阶,要求第k级台阶必须有k个硬币。问n个硬币最多能够搭多少级台阶?
如五个硬币最多能够搭两级台阶,8个硬币最多搭三级台阶。
1 | You have a total of n coins that you want to form in a staircase shape, where every k-th row must have exactly k coins. |
用n个硬币搭台阶,要求第k级台阶必须有k个硬币。问n个硬币最多能够搭多少级台阶?
如五个硬币最多能够搭两级台阶,8个硬币最多搭三级台阶。
1 | 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 subarrays. |
将一个长度为n的正整数数组分割为m个非空的连续子数组,并分别计算每个子数组中所有元素的和。求一种分割方式,使得该分割方式生成的最大子数组和为所有分割方式中最小的。
比如题目中的例子nums = [7,2,5,10,8],m = 2
一共有四种分割方式:
其中第三种分割得到的最大子数组的和 是所有分割中最小的
1 | You are given two non-empty linked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. |
对以链表形式的两个整数进行累加计算。
1 | A sequence of numbers is called a wiggle sequence if the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either positive or negative. A sequence with fewer than two elements is trivially a wiggle sequence. |
扭动序列是指数组中的相邻两个元素的差保证严格的正负交替,如[1,7,4,9,2,5]数组中相邻两个元素的差为6,-3,5,-7,3,满足扭动序列的要求。现在要求从一个数组中,找到长度最长的扭动子序列,并返回其长度。
1 | Given an array of integers where 1 ≤ a[ihexo] ≤ n (n = size of array), some elements appear twice and others appear once. |
假设一个长度为n的整数数组,数组中的元素的值位于[1,n]区间中。问,该数组中有哪些[1,n]区间中的整数没有出现?
1 | 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 does not exist, return -1.0. |
已知一些字母之间的关系式,问是否能够计算出其它字母之间的倍数关系?
如已知a/b=2.0 b/c=3.0问是否能够计算出a/c, b/a, a/e, a/a, x/x的值。如果无法计算得出,则返回-1。这里x/x的值因为在条件中无法获知x是否等于零,因此也无法计算其真实结果,也需要返回-1。
1 | Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection link to be reconstructed later in the same or another computer environment. |
将二叉搜索树序列化和反序列化,序列化是指将树用字符串的形式表示,反序列化是指将字符串形式的树还原成原来的样子。
1 | Given an n-ary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). |
1 | We should return its level order traversal: |
对N叉树进行水平遍历,并输出每一行遍历的结果。
1 | A sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same. |
将包含大于等于三个元素且任意相邻两个元素之间的差相等的数组成为等差数列。现在输入一个随机数组,问该数组中一共可以找出多少组等差数列。
1 | Given a non-empty string containing an out-of-order English representation of digits 0-9, output the digits in ascending order. |
一个非空的英文字符串,其中包含着乱序的阿拉伯数字的英文单词。如012对应的英文表达为zeroonetwo并继续乱序成owoztneoer。要求输入乱序的英文表达式,找出其中包含的所有0-9的数字,并按照从小到大输出。