共 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... 阅84 转0 评0 公众公开 17-11-10 10:38 |
阅68 转0 评0 公众公开 17-06-06 11:15 |
剑指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... 阅22 转0 评0 公众公开 17-06-06 11:00 |
剑指offer 56删除链表中重复的结点题目描述在一个排序的链表中,存在重复的结点,请删除该链表中重复的结点,重复的结点不保留,返回链表头指针。 阅42 转0 评0 公众公开 17-06-06 10:49 |
剑指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... 阅52 转0 评0 公众公开 17-06-06 09:58 |
阅25 转0 评0 公众公开 17-06-06 09:29 |
剑指offer 54字符流中第一个不重复的字题目描述请实现一个函数用来找出字符流中第一个只出现一次的字符。例如,当从字符流中只读出前两个字符"go"时,第一个只出现一次的字符是"g"。当从该字符流中读出前六个字符“google"时,第一个只出现一次的字符是"l"。如果当前字符流没有存在出现一次的字符,返回#字... 阅73 转0 评0 公众公开 17-06-06 09:19 |
阅182 转1 评0 公众公开 17-06-06 09:10 |
剑指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''&&... 阅28 转0 评0 公众公开 17-06-05 22:58 |
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... 阅30 转0 评0 公众公开 17-06-05 22:33 |