leetcode179】的更多相关文章

179. Largest Number Given a list of non negative integers, arrange them such that they form the largest number. For example, given [3, 30, 34, 5, 9], the largest formed number is 9534330. Note: The result may be very large, so you need to return a st…
题目: Given a list of non negative integers, arrange them such that they form the largest number. For example, given [3, 30, 34, 5, 9], the largest formed number is 9534330. Note: The result may be very large, so you need to return a string instead of…
Given a list of non negative integers, arrange them such that they form the largest number. Example 1: Input: [10,2] Output: "210" Example 2: Input: [3,30,34,5,9] Output: "9534330" Note: The result may be very large, so you need to ret…
class Solution { public: string largestNumber(vector<int>& nums) { int n=nums.size(); vector<string> strnums(n); ;i<n;++i) {//(1)首先将每个整型数转换为字符串 strnums[i] = to_string(nums[i]); } //(2)依据排序规则,将字符串排序 //这里排序的前后规是使得连接字符串较大的排在前面 //如虽然32<3…
给定一组非负整数,重新排列它们的顺序使之组成一个最大的整数. 示例 1: 输入: [10,2] 输出: 210 示例 2: 输入: [3,30,34,5,9] 输出: 9534330 说明: 输出结果可能非常大,所以你需要返回一个字符串而不是整数. 注意全是0的情况 bool cmp3(int x, int y) { string str1 = to_string(x); string str2 = to_string(y); return (str1 + str2) > (str2 + str…
水题: class Solution { public: string generateTheString(int n) { string s; string a="a",b="b"; ==){ ; i <= n - ; i++) s = s + a; s = s + b; } else{ ; i <= n ; i++) s = s + a; } return s; } }; 难题:1377. T 秒后青蛙的位置 思路:自底向上反推,从结果入手寻找答案…