mirror of
				https://git.wolves.top/wolves/leetcode.git
				synced 2025-11-04 17:26:32 +08:00 
			
		
		
		
	init
This commit is contained in:
		
							
								
								
									
										0
									
								
								else/Heap/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								else/Heap/README.md
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										34
									
								
								else/Heap/test.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								else/Heap/test.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,34 @@
 | 
			
		||||
//
 | 
			
		||||
// Created by 李洋 on 2023/10/18.
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
#ifndef LEECODE_C_TEST_H_P
 | 
			
		||||
#define LEECODE_C_TEST_H_P
 | 
			
		||||
 | 
			
		||||
#include <queue>
 | 
			
		||||
#include <iostream>
 | 
			
		||||
 | 
			
		||||
using namespace std;
 | 
			
		||||
 | 
			
		||||
void testPQ() {
 | 
			
		||||
    priority_queue<int, deque<int>, less<>> maxHeap;
 | 
			
		||||
    maxHeap.push(1);
 | 
			
		||||
    maxHeap.push(10);
 | 
			
		||||
    maxHeap.push(3);
 | 
			
		||||
    maxHeap.push(3);
 | 
			
		||||
    maxHeap.push(3);
 | 
			
		||||
    cout << maxHeap.top() << endl;
 | 
			
		||||
    maxHeap.pop();
 | 
			
		||||
    maxHeap.push(4);
 | 
			
		||||
    cout << maxHeap.top() << endl;
 | 
			
		||||
    maxHeap.pop();
 | 
			
		||||
    maxHeap.push(2);
 | 
			
		||||
    cout << maxHeap.top() << endl;
 | 
			
		||||
    priority_queue<int, vector<int>, greater<>> minHeap;
 | 
			
		||||
    minHeap.push(20);
 | 
			
		||||
    minHeap.push(10);
 | 
			
		||||
    minHeap.push(30);
 | 
			
		||||
    cout << minHeap.top() << endl;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif //LEECODE_C_TEST_H_P
 | 
			
		||||
		Reference in New Issue
	
	Block a user