This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int main(){ | |
const int c = 0; | |
int* p = (int*)&c; | |
printf("Begin...\n"); | |
*p = 5; | |
printf("c = %d\n",c); | |
printf("End...\n"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
// class Base { | |
// public: | |
// Base() = default; | |
// Base(int num){}; | |
// private: | |
// int num; | |
// }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
class base { | |
public: | |
base() = default; | |
~base() = default; | |
private: | |
int num; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Runtime: 12 ms, faster than 57.21% | |
//Memory Usage: 10.5 MB, less than 48.01% | |
class Solution { | |
public: | |
vector<string> fizzBuzz(int n) { | |
vector<string> array; | |
for(int i = 1;i <= n;++i){ | |
if(i % 3 == 0 && i % 5 != 0) | |
array.push_back("Fizz"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Runtime: 52 ms, faster than 96.57% | |
//Memory Usage: 8.5 MB, less than 5.67% | |
class Solution { | |
public: | |
bool isPowerOfThree(int n) { | |
return fmod(log10(n) / log10(3),1) == 0; | |
} | |
}; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Runtime: 16 ms, faster than 20.14% | |
//Memory Usage: 10.3 MB, less than 60.30% | |
class Solution { | |
public: | |
int maxSubArray(vector<int>& nums) { | |
if(nums.empty()) return NULL; | |
if(nums.size() == 1) return nums[0]; | |
int sum = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Runtime: 4 ms, faster than 100.00% | |
//Memory Usage: 8.2 MB, less than 17.32% | |
class Solution { | |
public: | |
int firstBadVersion(int n) { | |
long begin = 1; | |
long end = n; | |
long temp; | |
if(isBadVersion(1)) return 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Runtime: 8 ms, faster than 92.35% | |
//Memory Usage: 9.1 MB, less than 52.67% | |
class Solution { | |
public: | |
void merge(vector<int>& nums1, int m, vector<int>& nums2, int n) { | |
if(!nums2.empty()){ | |
for(int i = m,j = 0;i < m+n;i++,j++){ | |
nums1[i] = nums2[j]; | |
} |