- 1 问题 给的N个数字的数组,每个元素的大小范围大于等于0小于N(0 << a[i] < N),找出数组中有哪些数字重复了并且这个数字重复了多少次,一共有几个数字重复了。 2思路 由于元素的大小范围大于等于0小于N(0 << a[i] < N),我们直接把... 1 问题 给的N个数字的数组,每个元素的大小范围大于等于0小于N(0 << a[i] < N),找出数组中有哪些数字重复了并且这个数字重复了多少次,一共有几个数字重复了。 2思路 由于元素的大小范围大于等于0小于N(0 << a[i] < N),我们直接把...
- 1 问题 判断链表是否包含环 2 思路 2个指针,一个指针走一步,一个指针走2步,如果相遇则有,反之无。 3 代码实现 #include <stdio.h>#include <stdlib.h> #define true 1#def... 1 问题 判断链表是否包含环 2 思路 2个指针,一个指针走一步,一个指针走2步,如果相遇则有,反之无。 3 代码实现 #include <stdio.h>#include <stdlib.h> #define true 1#def...
- 1 问题 剑指offer之找到链表里面包含环的入口节点,比如 // node7<-node6 <-node5 // | | //head->node1->node2->node3->node4 环的入口节点是node2 2&n... 1 问题 剑指offer之找到链表里面包含环的入口节点,比如 // node7<-node6 <-node5 // | | //head->node1->node2->node3->node4 环的入口节点是node2 2&n...
- 1 memcpy 我们知道这个函数主要是拷贝内存数据,我们一般可以使用拷贝结构体到结构体、也可以拷贝字符数组到结构体,但是这个字符数组数据应该是同一个结构体拷贝先拷贝到这个字符数组,如果是其他格式的字符数组,这样拷贝就有问题。 2 测试... 1 memcpy 我们知道这个函数主要是拷贝内存数据,我们一般可以使用拷贝结构体到结构体、也可以拷贝字符数组到结构体,但是这个字符数组数据应该是同一个结构体拷贝先拷贝到这个字符数组,如果是其他格式的字符数组,这样拷贝就有问题。 2 测试...
- 1、题目 Given a string and an integer k, you need to reverse the first k characters for every 2k characters counting from the start of the string. If there are less than k characters left, ... 1、题目 Given a string and an integer k, you need to reverse the first k characters for every 2k characters counting from the start of the string. If there are less than k characters left, ...
- 1 完满二叉树 除了叶子结点之外的每一个结点都有两个孩子结点。 如下是完满二叉树 1 2 3 4 5 6 7 2 分析 我们按层(queue)遍历数,如果发现左子树为空右子树不为空 或者 左子树不为空右子树为空 的情况下直接返回false... 1 完满二叉树 除了叶子结点之外的每一个结点都有两个孩子结点。 如下是完满二叉树 1 2 3 4 5 6 7 2 分析 我们按层(queue)遍历数,如果发现左子树为空右子树不为空 或者 左子树不为空右子树为空 的情况下直接返回false...
- 有2中方案,分别用类和内部类实现了 import java.util.Stack; /** * @author chenyu 第一种设计: * 题目:设计一个有getMin功能的栈,设计一个特殊的栈,在实现栈的基本功能的基础上,再实现返回栈中最小元素的操作 * 要求:1 pop push getMin操作的时间复杂度都是O(1) * 2... 有2中方案,分别用类和内部类实现了 import java.util.Stack; /** * @author chenyu 第一种设计: * 题目:设计一个有getMin功能的栈,设计一个特殊的栈,在实现栈的基本功能的基础上,再实现返回栈中最小元素的操作 * 要求:1 pop push getMin操作的时间复杂度都是O(1) * 2...
- 1、题目 Given scores of N athletes, find their relative ranks and the people with the top three highest scores, who will be awarded medals: "Gold Medal", "Silver Medal" and "Bron... 1、题目 Given scores of N athletes, find their relative ranks and the people with the top three highest scores, who will be awarded medals: "Gold Medal", "Silver Medal" and "Bron...
- 1、题目 Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation. Note: The given integer is guaranteed to fi... 1、题目 Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation. Note: The given integer is guaranteed to fi...
- 1 希尔排序 在要排序的一组数中,根据某一增量分为若干子序列,并对子序列分别进行插入排序。 然后逐渐将增量减小,并重复上述过程。直至增量为1,此时数据序列基本有序,最后进行插入排序。 2 代码实现 #include <stdio.h> void print(int* data, i... 1 希尔排序 在要排序的一组数中,根据某一增量分为若干子序列,并对子序列分别进行插入排序。 然后逐渐将增量减小,并重复上述过程。直至增量为1,此时数据序列基本有序,最后进行插入排序。 2 代码实现 #include <stdio.h> void print(int* data, i...
- 1、题目 Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you im... 1、题目 Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you im...
- 问题描述: 要在8*8的国际象棋棋盘中放8个皇后,使任意两个皇后都不能互相吃掉。规则是皇后能吃掉同一行、同一列、同一对角线的棋子。如下图即是两种方案: 思路: 比如我们搞个数组,数组的下表表示多少行,然后数值表示多少列,比如a[4] = 5,意思就代表第四行,第五列 首先看不再同一行、同一列、同一对问题,我们数组依次增大,所以不会同... 问题描述: 要在8*8的国际象棋棋盘中放8个皇后,使任意两个皇后都不能互相吃掉。规则是皇后能吃掉同一行、同一列、同一对角线的棋子。如下图即是两种方案: 思路: 比如我们搞个数组,数组的下表表示多少行,然后数值表示多少列,比如a[4] = 5,意思就代表第四行,第五列 首先看不再同一行、同一列、同一对问题,我们数组依次增大,所以不会同...
- 假设有男人和女人两种元素,要分别打印出他们在不同状态时的不同表现。 用OO的思想把表现(行为)提取出来作为一个抽象方法,代码如下: 用if-else对状态进行判断 Person接口 public interface Person { public void action(String st... 假设有男人和女人两种元素,要分别打印出他们在不同状态时的不同表现。 用OO的思想把表现(行为)提取出来作为一个抽象方法,代码如下: 用if-else对状态进行判断 Person接口 public interface Person { public void action(String st...
- 1 问题 比如我们要遍历字符串数组,我们的思路一般是先求字符串数组的长度,然后再用for循环便利,其实没必要这样,我们直接在 字符串数组后面加上个NULL就行再去遍历 2 代码实现 #include <stdio.h... 1 问题 比如我们要遍历字符串数组,我们的思路一般是先求字符串数组的长度,然后再用for循环便利,其实没必要这样,我们直接在 字符串数组后面加上个NULL就行再去遍历 2 代码实现 #include <stdio.h...
- 1、题目 You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nums1's elements in the corr... 1、题目 You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nums1's elements in the corr...
上滑加载中
推荐直播
-
华为云码道Agent集成与鸿蒙实战2026/08/11 周二 19:00-21:00
王一男-华为云码道产品规划专家;李炎-华为云码道产品专家;彭江敏-华为云鸿蒙端云一体化开发专家
本次直播带你解读华为云码道7月份产品新特性、新功能。更有专家演示码道Agent Space × 钉钉机器集成实战,从0到1打通消息通道;码道鸿蒙端云一体化实战,快速搭建员工签到系统。
回顾中 -
华为云开发者AI素养直播课·第五期2026/09/04 周五 16:00-18:00
林华鼎-华为云AI开发者运营负责人;蒋春阳-华为云AI开发者案例开发专家
本期直播内容: AI工具体验营 · 第5-8课连讲。Agent-Team 多智能体协作完成毕业设计实践
回顾中 -
华为云开发者AI素养ClassRoom·第六期2026/09/08 周二 19:00-20:00
樊渊-2026华为软件挑战赛冠军
高手来了:看软挑高手解析二维排样问题—从工业难题到算法突破
回顾中
热门标签