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> | |
#include <vector> | |
using namespace std; | |
class Solution | |
{ | |
public: | |
int findMaxConsecutiveOnes(vector<int>& nums) | |
{ | |
int count = 0, max = 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
class Solution { | |
public: | |
int hammingDistance(int x, int y) { | |
const int MAX = 10000; | |
bool two_x[MAX] = {0}, two_y[MAX] = {0}; | |
int i = MAX-1, j = MAX-1; | |
int point = 0; | |
while(x>=2) | |
{ |
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 <algorithm> | |
class Solution { | |
public: | |
int arrayPairSum(vector<int>& nums) { | |
vector<int>::size_type sz = nums.size(); | |
sort(nums.begin(),nums.end()); | |
int total = 0; | |
for(int i=0;i<sz;i+=2) | |
{ | |
total+=nums[i]; |
NewerOlder