Leecode 0162. Find Peak Element
162. Find Peak Element题目A peak element is an element that is strictly greater than its neighbors. Given a 0-indexed integer array nums, find a peak element, and return its index. If the array contains multiple peaks, return the index to any of the peaks. You may imagine that nums[-1] = nums[n] = -∞. In other words, an element is always considered to be strictly greater than a neighbor that is outside the array. You must write an algorithm that runs in O(log n) time. Example...
从线性表到分布式(Data-Structures)
数据结构学习绪论线性表栈、队列、数组串树与二叉树图查找排序设计模式之禅 大话设计模式 数据结构与算法分析.C语言描述 大话数据结构 算法导论绪论线性表栈、队列、数组串树与二叉树图查找排序
Leetcode 0001. Two Sum
1. Two Sum题目Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use the same element twice. Example: 1234Given nums = [2, 7, 11, 15], target = 9,Because nums[0] + nums[1] = 2 + 7 = 9,return [0, 1]. 题目大意在数组中找到两个数,它们的和等于给定的目标值 target,并返回这两个数在数组中的下标。要求每个元素只能使用一次,且保证有且仅有一个解。 解题思路方法一:双层循环(暴力枚举)思路通过双重循环遍历数组中的每一对元素,检查它们的和是否等于目标值 target。外层循环控制第一个元素的索引...
Leetcode 0002. Add Two Numbers
2. Add Two Numbers题目You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list. You may assume the two numbers do not contain any leading zeros, except the number 0 itself. Example 1: 123Input: l1 = [2,4,3], l2 = [5,6,4]Output: [7,0,8]Explanation: 342 + 465 = 807. Example 2: 12Input: l1 = [0], l2 = [0]Output: [0] Example...
C语言日期工具完整实现
引言:为什么需要自己写日期工具?在开发日程管理、财务统计或数据分析类应用时,日期处理是绕不开的需求。虽然C标准库提供了相关函数,但实际场景中往往需要更灵活的功能——比如精确计算两个日期的天数差、自定义格式打印月历,或验证用户输入的日期合法性。今天我们就用C语言手写一个全功能日期工具,覆盖从基础判断到复杂交互的全流程,并拆解核心算法原理。 核心功能清单这个日期工具实现了5大核心功能,覆盖日常开发中最常用的日期操作场景: ✅ 计算日期差:精确计算任意两个日期之间的天数间隔; ✅ 查询星期几:输入年月日,快速得到对应的星期名称; ✅ 打印月历:以表格形式展示当月日期与星期的对应关系; ✅ 打印年历:按月份分开展示全年日历; ✅ 输入验证:自动检查日期合法性(如闰年二月是否有29天)。 关键数据与算法:日期计算的底层逻辑基础数据:月份天数与星期映射代码中定义了两个全局常量数组,它们是整个工具的「数据基石」: 1234const int mon[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 }; //...

