统计优美子数组。题意是给你一个整数数组 nums 和一个整数 k。如果某个 连续 子数组中恰好有 k 个奇数数字,我们就认为这个子数组是「优美子数组」。请返回这个数组中「优美子数组」的数目。例子, Example 1: Input: nums = [1,1,2,1,1], k = 3 Output: ...
分类:
其他好文 时间:
2020-04-21 09:47:16
阅读次数:
55
第一个是查找矩阵中的数字//递增矩阵查找k第二个是猜测五个跳水中的名次//第三个是调整数组奇数偶数//第四个是喝水问题//``第五个是水仙花问题//第六个是打印菱形问题//#define_CRT_SECURE_NO_WARNINGS#include<stdio.h>//intfind(intarr[3][3],intk,introw,intcol)//{//intx=0;//inty=
分类:
其他好文 时间:
2020-04-20 16:05:27
阅读次数:
72
给你一个整数数组 nums,请你返回其中位数为 偶数 的数字的个数。 示例 1: 输入:nums = [12,345,2,6,7896]输出:2解释:12 是 2 位数字(位数为偶数) 345 是 3 位数字(位数为奇数) 2 是 1 位数字(位数为奇数) 6 是 1 位数字 位数为奇数) 7896 ...
分类:
其他好文 时间:
2020-04-19 22:36:32
阅读次数:
91
给定一个单链表,把所有的奇数节点和偶数节点分别排在一起。请注意,这里的奇数节点和偶数节点指的是节点编号的奇偶性,而不是节点的值的奇偶性。 请尝试使用原地算法完成。你的算法的空间复杂度应为 O(1),时间复杂度应为 O(nodes),nodes 为节点总数。 示例 1: 输入: 1->2->3->4- ...
分类:
其他好文 时间:
2020-04-19 15:14:33
阅读次数:
60
题目链接:https://leetcode cn.com/problems/diao zheng shu zu shun xu shi qi shu wei yu ou shu qian mian lcof/ 双指针 ...
分类:
编程语言 时间:
2020-04-19 14:46:18
阅读次数:
64
题目连接: https://www.acwing.com/problem/content/1318/ Description 我们称一个长度为 2n 的数列是有趣的,当且仅当该数列满足以下三个条件: 1.它是从 1 到 2n 共 2n 个整数的一个排列 ${ai}$; 2.所有的奇数项满足 $a_1 ...
分类:
其他好文 时间:
2020-04-18 13:35:14
阅读次数:
60
思路:1、遍历A,取出其中的奇数(list1)、偶数(list2);2、下标为奇数时从list1中取一个元素插入;3、下标为偶数时从list2中取一个元素插入; 1 class Solution(object): 2 def sortArrayByParityII(self, A): 3 """ 4 ...
分类:
编程语言 时间:
2020-04-16 15:36:46
阅读次数:
76
题目 Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. 给定一个字符串 s,找到 s 中最长的回文子串。你可以假设 s ...
分类:
其他好文 时间:
2020-04-15 18:30:58
阅读次数:
59
$CF\ 634\ (Div3)$ $A.$ 给定 $n$,问有多少对正整数 $a,\ b$,使得 $a + b = n$ 且 $a b$ 如果 $n$ 是偶数,那么 $ans = n / 2 1$ 如果 $n$ 是奇数,那么 $ans = n / 2$ ...
分类:
其他好文 时间:
2020-04-15 01:01:37
阅读次数:
84
题意:将n分成a,b。保证a>b,问有几种分法 解析:偶数输出n/2-1,奇数n/2即可 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<set> using namespace s ...
分类:
其他好文 时间:
2020-04-14 21:06:18
阅读次数:
100