JZ36 两个链表的第一个公共结点 Solution 双指针 1234567891011121314151617181920/*struct ListNode { int val; struct ListNode *next; ListNode(int x) : val(x), next(NULL) { }};*/class Solution {public: 2021-10-08 algo 链表 nowcoder
JZ35 数组中的逆序对 Solution 分治法,借助归并思想 123456789101112131415161718192021222324252627282930313233343536373839404142class Solution {public: int InversePairs(vector<int> data) { if (data.siz 2021-10-08 algo nowcoder 数组
JZ34 第一个只出现一次的字符 Solution 利用哈希存储 123456789101112131415class Solution {public: int FirstNotRepeatingChar(string str) { if (str.size() == 0) return -1; unordered_map<char, int> uma 2021-10-08 algo 字符串 nowcoder
JZ33 丑数 Solution 动态规划 123456789101112131415161718class Solution {public: int GetUglyNumber_Solution(int index) { if (index < 7) return index; int two = 1, three = 1, five = 2021-10-08 algo 动态规划 nowcoder
JZ32 把数组排成最小的数 Solution 字符串比较 1234567891011121314151617181920class Solution {public: string PrintMinNumber(vector<int> numbers) { vector<string> record; for (int num : nu 2021-10-08 algo nowcoder 数组
JZ31 整数中1出现的次数 Solution 利用规律 1234567891011121314151617181920212223class Solution {public: int NumberOf1Between1AndN_Solution(int n) { long digit = 1; int high = n / 10, cur = n % 10, 2021-10-08 algo 数学 nowcoder
JZ30 连续子数组的最大和 Solution 贪心算法 12345678910111213class Solution {public: int FindGreatestSumOfSubArray(vector<int> array) { int res = INT_MIN; int sum = 0; for (int num : a 2021-10-08 algo 贪心算法 nowcoder
JZ29 最小的K个数 Solution 优先队列 123456789101112131415161718192021class Solution {public: vector<int> GetLeastNumbers_Solution(vector<int> input, int k) { vector<int> res; 2021-10-08 algo nowcoder 数组
JZ28 数组中出现次数超过一半的数字 Solution 投票法 123456789101112131415161718class Solution {public: int MoreThanHalfNum_Solution(vector<int> numbers) { int candidate = 0, votes = 0; for (int num : 2021-10-08 algo nowcoder 数组
JZ27 字符串的排列 Solution 回溯法 123456789101112131415161718192021222324252627282930313233343536class Solution {public: vector<string> Permutation(string s) { int n = s.size(); if ( 2021-10-08 algo 字符串 nowcoder