C++笔试-剑指offer

news2024/9/21 16:24:41

剑指offer

文章目录

  • 剑指offer
    • 数组
      • [数组中重复的数据 ](https://leetcode.cn/problems/find-all-duplicates-in-an-array/description/)
        • 将元素交换到对应的位置
      • 二维数组中的查找
        • 二叉搜索树
      • 旋转数组的最小数字
        • 二分查找
      • 数组中出现次数超过一半的数字
        • 相互抵消
      • 连续子数组的最大和(二)
        • 动态规划
    • 链表
      • 从尾到头打印链表
        • 反转链表(双指针、递归)
        • 拓展:反转链表中间一部分
      • 删除链表的节点
      • 链表合并
      • 链表中倒数最后k个结点
        • 双指针思想
      • 复杂链表的复制
        • 哈希表
        • 在每个旧节点后加上新节点
      • 删除有序链表中重复的元素-I
        • 双指针思想
      • 删除链表中重复的结点
    • 二叉树
      • 二叉树的深度
        • 递归
      • 二叉树的最小深度
      • 二叉树的镜像
    • 队列、栈
      • 用两个栈实现队列
    • 动态规划
    • 跳台阶
        • DP(ACM模式)
        • 递归(ACM模式)

数组

数组中重复的数据

将元素交换到对应的位置
class Solution {
public:
    vector<int> findDuplicates(vector<int>& nums) {
        vector<int> result;
        for (int i = 0; i<nums.size();i++)
        {
            while (nums[i] != nums[nums[i]-1])
            {
                swap(nums[i],nums[nums[i]-1]);
            }
        }
        for (int i = 0; i<nums.size();i++)
        {
            if (nums[i]-1 != i)
            {
                result.push_back(nums[i]);
            }
        }
        return result;
    }
};

时间复杂度O(n)

空间复杂度O(1)

二维数组中的查找

二叉搜索树
class Solution{
public:
    bool Find(int target, vector<vector><int> arr){
        if (arr.empty() || arr[0].empty()) return false;
        int i = 0;//行
        int j = arr.size()-1;//列
        while (i<=arr.size()-1 && j>=0)
        {
            if (target == arr[i][j])
                return true;
            else if (tartget < arr[i][j])
                --j;
            else
                ++i;
        }
        return false;
    }
}

类似于二叉搜索树:

1

旋转数组的最小数字

二分查找

最小值一定在右区域!

class Solution {
public:
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     * 
     * @param nums int整型vector 
     * @return int整型
     */
    int minNumberInRotateArray(vector<int>& nums) {
        int left = 0, right = nums.size()-1;
        int mid;
        while (left<right)
        {
            mid = (left + right)/2;
            if (nums[left]<nums[right])//left一定在左区域或最低点,right一定在右区域,左区域的数一定大于等于右区域的数
            return nums[left];
            if (nums[mid] > nums[right])//mid在左区域,最小的数字在mid右边
            {
                left = mid + 1;
            }
            else if (nums[mid] == nums[right])//mid在重复元素
            {
                --right;
            }
            else //mid在右区域, 最小数字要么是mid要么在mid左边
            {
                right = mid;
            }
            
        }
        return nums[left];
    }
};

数组中出现次数超过一半的数字

相互抵消

用不同数字相互抵消的方法,最后留下来的一定是超过一半的数字

    int MoreThanHalfNum_Solution(vector<int>& numbers) {
        // write code here
        int num = numbers[0];
        int count = 1;
        for (int i = 1; i<numbers.size(); ++i)
        {
            if (count > 0)
            {
                if (numbers[i]==num)
                {
                    ++count;
                }
                else 
                {
                    --count;
                }
            }
            else //count = 0
            {
                num = numbers[i];
                count = 1;
            }
        }
        return num;
    }
};

1287. 有序数组中出现次数超过25%的元素

由于这题是升序,可以直接用步长判断,也可以用上题的步骤判断

连续子数组的最大和(二)

根据剑指offer自己想的,待优化:

int最大值INT_MAX,最小值INT_MIN

int的最小值可以写成0x8000000,最大值可以写成0x7FFFFFFF

class Solution {
public:
    vector<int> FindGreatestSumOfSubArray(vector<int>& arr) {
        // write code here
        int result = 0x80000000;
        vector<int> vresult;
        vector<int> temp;
        int sum = 0;
        for (int i =0;i<arr.size();++i)
        {
            if (sum<0)//如果和为负数,那么前一个和一定是从那个元素开始算的最大和了
            {
                temp.clear();
                temp.push_back(arr[i]);
                sum=arr[i];
            }
            else 
            {
                sum+=arr[i];
                temp.push_back(arr[i]);
            }
            if (sum>=result)
            {
                result = sum;
                vresult = temp;
            }
        }
        return vresult;
    }
};
动态规划
//只需要保存最大值时:
int res = nums[0];
for (int i = 1; i < nums.size(); i++) {
    if (nums[i - 1] > 0) nums[i] += nums[i - 1];
    if (nums[i] > res) res = nums[i];
}
return res;
//需要保存对应的子数组时:

求连续子数组的最大和(ACM模式)

#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
    string str;
    cin>>str;//输入是个字符串
    int k =0;
    vector<int> numbers;
    while((k = str.find(',')) != str.npos){//注意输出的方法
        string temp = str.substr(0, k);
        numbers.push_back(stoi(temp));
        str = str.substr(k + 1);
    }
    numbers.push_back(stoi(str));
    int tempmax = 0;
    int result = 0x80000000;
    int sum = 0;
    for (int i =0; i<numbers.size();++i)
    {
        if (sum<0)
        {
            sum=numbers[i];
        }
        else 
        {
            sum+=numbers[i];
        }
        result = max(sum,result);
    }
    if (result<0)
    {
        result = 0;
    }
    printf("%d",result);
}
// 64 位输出请用 printf("%lld")

链表

从尾到头打印链表

利用栈先入后出的特点,很好解决

class Solution {
public:
    vector<int> printListFromTailToHead(ListNode* head) {
        stack<int> stk;
        vector<int> result;
        int value = 0;
        while (head!=nullptr)
        {
            stk.push(head->val);
            head = head->next;
        }
        while (!stk.empty())
        {
            value = stk.top();
            result.push_back(value);
            stk.pop();
        }
        return result;
    }
};

时间复杂度O(n)

空间复杂度O(n)

反转链表(双指针、递归)

双指针:

class Solution {
public:
    vector<int> printListFromTailToHead(ListNode* head) {
        ListNode* preNode = nullptr;
        ListNode* curNode = head;
        
        while(curNode!=nullptr)
        {
            ListNode* temp = curNode->next;
            curNode->next = preNode;
            preNode = curNode;
            curNode = temp;
        }
        vector<int> result;
        while(preNode!=nullptr)
        {
            result.push_back(preNode->val);
            preNode = preNode->next;
        }
        return result;
    }
};

时间复杂度O(n)

空间复杂度O(1)

递归

class Solution {
public:
    vector<int> printListFromTailToHead(ListNode* head) {
        ListNode* newhead = ReverseList(head);
        vector<int> result;
        while (newhead!=nullptr)
        {
            result.push_back(newhead->val);
            newhead = newhead->next;
        }
        return result;
    }

    ListNode* ReverseList(ListNode* head)
    {
        if (head==nullptr || head->next==nullptr)
        {
            return head;
        }
        ListNode* newhead = ReverseList(head->next);
        head->next->next = head;
        head->next = nullptr;
        return newhead;
    }
};

时间复杂度O(n)

空间复杂度O(n)

拓展:反转链表中间一部分

92. 反转链表 II - 力扣(LeetCode)

class Solution {
public:
    ListNode* reverseBetween(ListNode* head, int left, int right) {
        if (head->next==nullptr || left==right)
        {
            return head;
        }
        ListNode* dummyhead = new ListNode(0);
        dummyhead->next = head;
        ListNode* preleftEdge = dummyhead;
        ListNode* leftEdge = head;
        ListNode* rightEdge = head;
        for(int i = 1; i<left;++i)
        {
            preleftEdge = preleftEdge->next;
            leftEdge = preleftEdge->next;
        }
        for(int i = 1; i<right;++i)
        {
            rightEdge = rightEdge->next;
        }
        ListNode* nextrightEdge = rightEdge->next;
        
        ListNode* leftNode = leftEdge;
        ListNode* firstNode = leftNode;
        ListNode* rightNode = leftNode->next;
        while (rightNode!=nextrightEdge)
        {
            ListNode* temp = rightNode->next;
            rightNode->next = leftNode;
            leftNode = rightNode;
            rightNode = temp;
        }
        preleftEdge->next = leftNode;
        firstNode->next = nextrightEdge;
        return dummyhead->next;
    }
};

删除链表的节点

class Solution {
public:
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     * 
     * @param head ListNode类 
     * @param val int整型 
     * @return ListNode类
     */
    ListNode* deleteNode(ListNode* head, int val) {
        // write code here
        ListNode* dummyhead = new ListNode(0);
        dummyhead->next = head;
        ListNode* pre = dummyhead;
        ListNode* cur = head;
        while (cur!=nullptr)
        {
            if (cur->val==val)
            {
                pre->next = cur->next;
                break;
            }
            else 
            {
                cur = cur->next;
                pre = pre->next;
            }
        }
        return dummyhead->next;
    }
};

还有一种不需要知道前驱结点就可以“删除”链表结点的方法,前提是不能删除最后一个结点:

class Solution {
public:
    void deleteNode(ListNode* node) {
        node->val = node->next->val;
        node->next = node->next->next;
    }
};

链表合并

ACM模式的话要注意输入输出,然后要注意cur指针的更新

#include <iostream>
using namespace std;
struct ListNode
{
    int val;
    ListNode* next;
    ListNode(int val): val(val), next(nullptr){}
};

int main() {
    int a;
    ListNode* dummyhead = new ListNode(0);
    ListNode* cur = dummyhead;
    ListNode* dummyhead1 = new ListNode(0);
    ListNode* cur1 = dummyhead1;
    ListNode* dummyhead2 = new ListNode(0);
    ListNode* cur2 = dummyhead2;
    while(cin>>a)
    {
        ListNode* node = new ListNode(a);
        cur1->next = node;
        cur1 = cur1->next;
        if(cin.get()=='\n')
        {
        break;
        }
    }
    while(cin>>a)
    {
        ListNode* node = new ListNode(a);
        cur2->next = node;
        cur2 = cur2->next;
    }
    cur1 = dummyhead1->next;
    cur2 = dummyhead2->next;
    while (cur1!=nullptr && cur2!=nullptr)
    {
        if (cur1->val<=cur2->val)
        {
            cur->next = cur1;
            cur1 = cur1->next;
        }
        else 
        {
            cur->next = cur2;
            cur2 = cur2->next;
        }
        cur = cur->next;
    }
    if (cur1==nullptr)
    {
        cur->next = cur2;
    }
    if (cur2==nullptr)
    {
        cur->next = cur1;
    }
    
    cur = dummyhead->next;
    
    while (cur!=nullptr)
    {
        printf("%d ",cur->val);
        cur = cur->next;
    }
    return 0;
}
// 64 位输出请用 printf("%lld")

链表中倒数最后k个结点

双指针思想

右指针指向左指针后k个元素,这样当右指针为最后一个节点后的元素时,左指针指向的就是所求元素

/**
 * struct ListNode {
 *	int val;
 *	struct ListNode *next;
 *	ListNode(int x) : val(x), next(nullptr) {}
 * };
 */
class Solution {
public:
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     * 
     * @param pHead ListNode类 
     * @param k int整型 
     * @return ListNode类
     */
    ListNode* FindKthToTail(ListNode* pHead, int k) {
        // write code here
        if (pHead==nullptr)
        {
            return nullptr;
        }
        ListNode* left = pHead;
        ListNode* right = left;
        for (int i =0; i<k;++i)
        {
            if(right==nullptr)
            {
                return nullptr;
            }
            right = right->next;  
        }
        while (right!=nullptr)
        {
            right = right->next;
            left = left->next;
        }
        return left;
    }
};

复杂链表的复制

LCR 154. 复杂链表的复制 - 力扣(LeetCode)

哈希表

键为旧指针,值为新指针。第一次遍历时初始化键和值的label,第二次赋上next和random指针

class Solution {
public:
    Node* copyRandomList(Node* head) {
        if (head==nullptr)
        {
            return nullptr;
        }

        unordered_map<Node*,Node*> mp;

        Node* cur = head;
        while (cur!=nullptr)
        {
            Node* newNode = new Node(cur->val);
            mp[cur] = newNode;
            cur = cur->next;
        }
        cur = head;
        while (cur!=nullptr)
        {
            mp[cur]->next = mp[cur->next];
            mp[cur]->random = mp[cur->random];
            cur = cur->next;
        }
        return mp[head];

    }
};
在每个旧节点后加上新节点

最后要记得把旧链表头结点断开连接

class Solution {
public:
    RandomListNode* Clone(RandomListNode* pHead) {
        if (pHead==nullptr)
        {
            return nullptr;
        }
		//初始化next
        RandomListNode* cur1 = pHead;
        while (cur1!=nullptr)
        {
            RandomListNode* newNode = new RandomListNode(cur1->label);
            newNode->next = cur1->next;
            cur1->next = newNode;
            cur1 = cur1->next->next;
        }
		//赋值random
        cur1 = pHead;
        RandomListNode* cur2 = pHead->next;
        while (cur1!=nullptr)
        {
            if (cur1->random != nullptr)
            {
                cur2->random = cur1->random->next;
            }
            cur1 = cur1->next->next;
            cur2 = cur2->next->next;
        }
		//拆分链表
        RandomListNode* newCloneHead = pHead->next;
        cur2 = newCloneHead;
        pHead->next = nullptr;
        while (cur2->next!=nullptr)
        {
            cur2->next = cur2->next->next;
            cur2 = cur2->next;
        }
        cur2->next=nullptr;
        cur1 = pHead;
        cur2 = pHead->next;

        return newCloneHead;
    }
};

删除有序链表中重复的元素-I

双指针思想
    ListNode* deleteDuplicates(ListNode* head) {
        // write code here
        if (head==nullptr)
        {
            return nullptr;
        }
        ListNode* dummyhead = new ListNode(0);
        ListNode* left = dummyhead;
        ListNode* right = head;
        while(right!=nullptr)
        {
            while (right->next!=nullptr && right->val==right->next->val)
            {
                right = right->next;
            }
            left->next = right;
            left = left->next;
            right = right->next;
        }
        return dummyhead->next;
    }

删除链表中重复的结点

比前面多了再将right右移一步的动作,以及最后要把left指向nullptr

class Solution {
public:
    ListNode* deleteDuplication(ListNode* pHead) {
        if (pHead==nullptr)
        {
            return nullptr;
        }
        ListNode* dummyhead = new ListNode(0);
        ListNode* left = dummyhead;
        ListNode* right = pHead;
        while(right!=nullptr)
        {
            if(right->next!=nullptr && right->val==right->next->val)
            {
                while (right->next!=nullptr && right->val==right->next->val)
                {
                right = right->next;
                }
                right = right->next;
                continue;
            }
            left->next = right;
            left = left->next;
            right = right->next;
        }
        left->next = nullptr;
        return dummyhead->next;
    }
};

二叉树

二叉树的深度

递归

返回左子树和右子树深度的最大值加上一(后序遍历)

class Solution {
public:
    int TreeDepth(TreeNode* pRoot) {
		if (pRoot==nullptr)
		{
			return 0;
		}
		return max(TreeDepth(pRoot->left),TreeDepth(pRoot->right))+1;
		
    }
};

二叉树的最小深度

111. 二叉树的最小深度 - 力扣(LeetCode)

和二叉树的(最大)深度的区别是,计算的是到叶子节点(左右孩子都为空)的最小深度,也用后序遍历实现

class Solution {
public:
    int minDepth(TreeNode* root) {
        if (root==nullptr)
        {
            return 0;
        }
        if (root->left==nullptr && root->right!=nullptr)
        {
            return minDepth(root->right)+1;
        }
        else if (root->right==nullptr && root->left!=nullptr)
        {
            return minDepth(root->left)+1;
        }
        else
        {
            return min(minDepth(root->left),minDepth(root->right))+1;
        }
    }
};

二叉树的镜像

LCR 144. 翻转二叉树 - 力扣(LeetCode)

前序遍历

TreeNode* Mirror(TreeNode* pRoot) {
        // write code here
        if (pRoot==nullptr) return pRoot;
        swap(pRoot->left,pRoot->right);
        Mirror(pRoot->left);
        Mirror(pRoot->right);
        return pRoot;
    }

后序遍历

TreeNode* Mirror(TreeNode* pRoot) {
        // write code here
        if (pRoot==nullptr) return pRoot;
        Mirror(pRoot->left);
        Mirror(pRoot->right);
        swap(pRoot->left,pRoot->right);
        return pRoot;
    }

队列、栈

用两个栈实现队列

每当要pop的时候就获取stack2的最上面的元素,如果stack2为空,则将stack1依次出栈到stack2。这样stack2上面的就是最先push进去的元素,最底下是最新push进去的元素。

class Solution
{
public:
    void push(int node) {
        stack1.push(node);
    }

    int pop() {
        while (!stack2.empty())
        {
            int result = stack2.top();
            stack2.pop();
            return result;
        }
        while (!stack1.empty())
        {
            int temp = stack1.top();
            stack2.push(temp);
            stack1.pop();
        }
        int result = stack2.top();
        stack2.pop();
        return result;
    }

private:
    stack<int> stack1;
    stack<int> stack2;
};

动态规划

跳台阶

DP(ACM模式)
#include <iostream>
#include <unordered_map>

using namespace std;

int main() {
    int a;
    cin>>a;
    unordered_map<int,int> dp;
    dp[0] = 1;
    dp[1] = 1;
    dp[2] = 2;
    if (a<=2)
    {
        printf("%d",dp[a]);
    }
    else {
    for (int i=3;i<=a;i++)
    {
        int temp = dp[2];
        dp[2] +=dp[1];
        dp[1] = temp;
    }
    printf("%d",dp[2]);
    }
    
    return 0;
}
// 64 位输出请用 printf("%lld")

递归(ACM模式)
#include <iostream>
using namespace std;
 
int Jump(int num)
{
    if (num==0) return 1;
    if (num==1) return 1;
    if (num==2) return 2;
    return Jump(num-1) + Jump(num-2);
}
 
int main() {
    int a;
    cin>>a;
    int result = Jump(a);
    printf("%d",result);
    return 0;
}
// 64 位输出请用 printf("%lld")

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1808389.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

【Python Cookbook】S02E03 fnmatch 模块做字符串匹配

目录 问题解决方案讨论 问题 在不同的操作系统下&#xff0c;怎样做字符串匹配&#xff1f; 解决方案 fnmatch() 模块提供两个函数&#xff0c;fnmatch() 以及 fnmatchcase() 可以用来执行做这样的匹配。 from fnmatch import fnmatch, fnmatchcasematch_res fnmatch(foo.…

TikTok Shop账号需要防关联吗?

在TikTokShop作为新兴的电商销售渠道中&#xff0c;保护账号的安全和隐私&#xff0c;防止账号关联成为了重要的任务。为了更好地理解为何需要防关联以及如何进行防范&#xff0c;让我们深入探讨一下这个问题。 为什么要防关联&#xff1f; 1. 账号异常风险&#xff1a;防关联…

Nvidia/算能 +FPGA+AI大算力边缘计算盒子:桥梁结构安全监测

中国铁路设计集团有限公司&#xff08;简称中国铁设&#xff09;&#xff0c;原铁道第三勘察设计院集团有限公司&#xff08;铁三院&#xff09;&#xff0c;是中国国家铁路集团有限公司所属的唯一设计企业&#xff0c;成立于1953年&#xff0c;总部位于天津市&#xff0c;是以…

【FreeRTOS】创建第一个多任务程序

创建第1个多任务程序 韦东山 Freertos学习 第一个多任务程序创建 1. 目标 创建两个任务&#xff0c;任务A运行Led_Test&#xff0c;任务B运行LCD_Test。 硬件平台&#xff1a;DShanMCU-F103开发板 2. 接口函数 创建任务的API函数 不同操作系统有不同的创建API函数 FreeRTO…

2024-6-10 石群电路-28

2024-6-10&#xff0c;星期一&#xff0c;14:15&#xff0c;天气&#xff1a;晴&#xff0c;心情&#xff1a;晴。今天又是阳光明媚的一天&#xff0c;自从减肥成功and道家养生后&#xff0c;越来越感觉夏热冬冷&#xff0c;夏长冬藏这一自然规律了&#xff0c;虽然外面艳阳高照…

Capture One 23 软件安装教程、附安装包下载

Capture One Capture One 23 是一款功能极为全面的图片处理软件&#xff0c;为用户提供了真正的逼真色彩处理和无缝衔接的编辑体验&#xff0c;以及业界最快的联机拍摄功能&#xff0c;可以满足用户在图像创作上的所有功能&#xff0c;如创作全景拼接大图、高级色彩调整、遮罩…

每日5题Day20 - LeetCode 96 - 100

每一步向前都是向自己的梦想更近一步&#xff0c;坚持不懈&#xff0c;勇往直前&#xff01; 第一题&#xff1a;96. 不同的二叉搜索树 - 力扣&#xff08;LeetCode&#xff09; class Solution {public int numTrees(int n) {if(n < 2){return 1;}int[] dp new int[n 1]…

Signac|成年小鼠大脑 单细胞ATAC分析(2)

引言 在本教程中&#xff0c;我们将探讨由10x Genomics公司提供的成年小鼠大脑细胞的单细胞ATAC-seq数据集。本教程中使用的所有相关文件均可在10x Genomics官方网站上获取。 本教程复现了之前在人类外周血单核细胞&#xff08;PBMC&#xff09;的Signac入门教程中执行的命令。…

XMind v24.04.1 全功能VIP版(思维升级,效率飞跃)

软件介绍 XMind 是一款功能丰富的思维导图和创新构思工具&#xff0c;可在多个平台助力高效思考。它涵盖了从灵感触发、结构构建到演示展示的完整思维过程&#xff0c;有效提升创建思维导图的效率。这款工具适用于记录灵感、创新思维、问题解决和效率提升等多元场景&#xff0…

永久免费的iPhone,iPad,Mac,iWatch锁屏,桌面壁纸样机生成器NO.105

使用这个壁纸样机生成器&#xff0c;生成iPhone&#xff0c;iPad&#xff0c;Mac&#xff0c;iWatch锁屏&#xff0c;桌面壁纸&#xff0c;展示你的壁纸作品&#xff0c;一眼就看出壁纸好不好看&#xff0c;适不适合 资源来源于网络&#xff0c;免费分享仅供学习和测试使用&am…

内网穿透的方式有哪些——快解析的优势

外网穿透内网技术&#xff0c;即内网映射&#xff0c;是把目标本地内网地址和端口发布到互联网&#xff0c;是一种由内网开放到外网的权限操作。那么&#xff0c;内网穿透的方法有哪些呢&#xff1f;做映射外网的方法。需要结合自己本地网络环境和应用场景来实施。这里分享三种…

【Unity Shader入门精要 第13章】使用深度和法线纹理(二)

1. 再谈运动模糊 之前的文章中曾经通过保存渲染结果进行叠加的方式实现过运动模糊效果&#xff0c;下面的例子我们通过深度纹理重建世界坐标的方式来实现运动模糊&#xff1a; 首先&#xff0c;基于深度纹理重建像素的世界坐标&#xff0c;原理在【Unity Shader入门精要 第13…

LangChain开发【NL2SQL】应用

前言 关于LangGraph的简单介绍&#xff0c;请参考这篇博客&#xff1a; LangGraph开发Agent智能体应用【基础聊天机器人】-CSDN博客 对比LangChain实现NL2SQL 关于用LangChain开发NL2SQL的Agent应用&#xff0c;在这篇博客提供了完整的代码实现&#xff1a; LangChain开发…

数据结构笔记 线性表的查找 顺序,折半,分块查找

顺序查找&#xff1a;从头找到尾&#xff0c;或者从尾找到头 顺序查找的性能&#xff1a; 其中&#xff0c;辅助空间的O&#xff08;1&#xff09;用于存放哨兵的 折半查找&#xff1a;向下取整&#xff1a;指当计算的结果不为整数时取小于计算结果的整数。 折半查找的性能&am…

未来几年,同样的性能,推理功耗降低为现在的几万分之一,有可能吗

未来几年,同样的性能,推理功耗降低为现在的几万分之一,有可能吗 一.数据二.抓取LLM排行榜,相同的MMLU精度,模型参数量缩减倍数三.其它 有人说未来几年,推理功耗能降低为现在的几万分之一,好奇怎么能做到呢 一.数据 二.抓取LLM排行榜,相同的MMLU精度,模型参数量缩减倍数 import…

【LeetCode算法】第112题:路径总和

目录 一、题目描述 二、初次解答 三、官方解法 四、总结 一、题目描述 二、初次解答 1. 思路&#xff1a;二叉树先序遍历。首先访问根节点&#xff0c;若根节点是叶子节点并且值等于目标值&#xff0c;则返回true&#xff0c;否则递归访问左子树和右子树&#xff0c;只要左…

跨境电商|Facebook Marketplace怎么做?

2016 年&#xff0c;Facebook打造了同名平台 Facebook Marketplace。通过利用 Facebook 现有的庞大客户群&#xff0c;该平台取得了立竿见影的成功&#xff0c;每月访问量将超过 10 亿。对于个人卖家和小企业来说&#xff0c;Facebook Marketplace是一个不错的销货渠道&#xf…

激活乡村振兴新动能:推动农村产业融合发展,打造具有地方特色的美丽乡村,实现乡村全面振兴

目录 一、推动农村产业融合发展 1、农业产业链条的延伸 2、农业与旅游业的结合 二、挖掘地方特色&#xff0c;打造美丽乡村 1、保护和传承乡村文化 2、发展特色农业 三、加强基础设施建设&#xff0c;提升乡村品质 1、改善农村交通条件 2、提升农村水利设施 四、促进…

PHP“well”运动健身APP-计算机毕业设计源码87702

【摘要】 随着互联网的趋势的到来&#xff0c;各行各业都在考虑利用互联网将自己的信息推广出去&#xff0c;最好方式就是建立自己的平台信息&#xff0c;并对其进行管理&#xff0c;随着现在智能手机的普及&#xff0c;人们对于智能手机里面的应用“well”运动健身app也在不断…

树莓派Pico开发板与Gravity语音识别模块接口及其语音控制MicroPython编程

**摘要:**介绍Gravity语音识别模块的主要功能及其特性,讲述树莓派Pico与Gravity语音识别模块接口连接的基本方法,介绍使用Gravity语音识别模块学习语音唤醒词/命令词并给出I2C通信接口语音识别MicroPython库,以及基于树莓派Pico开发板和Gravity语音识别模块的语音控制Micro…