共 64 篇文章
显示摘要每页显示  条
元素3在数组中以R[0]表示,它的左孩子结点是R[1],右孩子结点是R[2]。元素8在数组中以R[1]表示,它的左孩子结点是R[3],右孩子结点是R[4],它的父结点是R[0]。(1)根据初始数组去构造初始堆(构建一个完全二叉树,保证所有的父结点都比它的孩子结点数值大)。2 3 public class HeapSort { 4 5 public void HeapAdjust(int[] array, in...
剑指offer 56删除链表中重复的结点题目描述在一个排序的链表中,存在重复的结点,请删除该链表中重复的结点,重复的结点不保留,返回链表头指针。*/class Solution {public: ListNode* deleteDuplication(ListNode* pHead) { if(pHead==0){ return 0;ListNode* p=pHead;} while(m[pHead->val]>1){ pHead=pHead->next;ListNode* p2=pHe...
剑指offer 56删除链表中重复的结点题目描述在一个排序的链表中,存在重复的结点,请删除该链表中重复的结点,重复的结点不保留,返回链表头指针。
剑指offer 55链表中环的入口结点题目描述一个链表中包含环,请找出该链表的环的入口结点。*/class Solution {public: ListNode* EntryNodeOfLoop(ListNode* pHead) {if(pHead==NULL||pHead->next==NULL||pHead->next->next==NULL){ return NULL;} ListNode* fast=pHead->next->next;ListNode* slow=pHead->next;=nullptr){ f...
剑指offer 54字符流中第一个不重复的字题目描述请实现一个函数用来找出字符流中第一个只出现一次的字符。例如,当从字符流中只读出前两个字符"go"时,第一个只出现一次的字符是"g"。当从该字符流中读出前六个字符“google"时,第一个只出现一次的字符是"l"。如果当前字符流没有存在出现一次的字符,返回#字...
剑指offer 52表示数值的字符串题目描述请实现一个函数用来判断字符串是否表示数值(包括整数和小数)。class Solution {public: bool isNumeric(char* string) { int len=strlen(string);} if(string[0]==''+''||string[0]==''-''){ i++;} while(i<len){ if(string[i]>=''0''&&...
class Solution {public: // Parameters: // numbers: an array of integers // length: the length of array numbers // duplication: (Output) the duplicated number in the array number // Return value: true if the input is valid, and there are some duplications in the array number // otherwise false bool duplicate(int number...
帮助 | 留言交流 | 联系我们 | 服务条款 | 下载网文摘手 | 下载手机客户端
北京六智信息技术股份有限公司 Copyright© 2005-2024 360doc.com , All Rights Reserved
京ICP证090625号 京ICP备05038915号 京网文[2016]6433-853号 京公网安备11010502030377号
返回
顶部