This file contains 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 <assert.h> | |
#include <vector> | |
#include <cmath> | |
#include <algorithm> | |
#include <string> | |
#include <set> | |
#include <climits> |
This file contains 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> | |
#include <map> | |
#include <cmath> | |
#include <algorithm> | |
#include <queue> | |
#include <unordered_set> | |
#include <unordered_map> | |
#include <string> | |
#include <set> |
This file contains 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> | |
#include <map> | |
#include <cmath> | |
#include <algorithm> | |
#include <queue> | |
#include <unordered_set> | |
#include <unordered_map> | |
#include <string> | |
#include <set> |
This file contains 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: | |
vector<int> productExceptSelf(vector<int>& nums) { | |
vector<int> ans = vector<int>(nums.size(), 1); | |
int front = 1; | |
int back = 1; | |
for (int i = 0; i < nums.size(); ++i) | |
{ | |
front *= nums[i]; | |
back *= nums[nums.size() - i - 1]; |
This file contains 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 <vector> | |
#include <iostream> | |
using namespace std; | |
struct Box | |
{ | |
int w, h, d; | |
bool operator < (cost Box& b) const { | |
if(w == b.w){ |
This file contains 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 <string> | |
using namespace std; | |
void printDoubleFromBinary(string binary){ | |
double ans = 0; | |
double tmp = 1.0; | |
for (int i = 0; i < binary.length(); ++i) | |
{ |
This file contains 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> | |
#include <algorithm> | |
using namespace std; | |
class Screen | |
{ | |
private: | |
int size; |
This file contains 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 <string> | |
using namespace std; | |
void print_bit(int n) { | |
string ans = ""; | |
while(n > 0) { | |
if(n & 1) { | |
ans = "1" + ans; |
This file contains 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 <algorithm> | |
using namespace std; | |
int best_reverse_len(int n){ | |
if(n == 0) return 1; | |
int cur = 0; | |
int before = 0; | |
int ans = 0; |
This file contains 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 { | |
private: | |
unordered_map<string, vector<string> > trie; | |
unordered_map<int, vector<string> > um; | |
vector<vector<string> > ans; | |
public: | |
vector<vector<string>> wordSquares(vector<string>& words) { | |
for(auto x : words) um[x.length()].push_back(x); | |
for (auto itr = um.begin(); itr != um.end(); ++itr) | |
{ |
NewerOlder