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: | |
vector<int> majorityElement(vector<int>& v) { | |
vector<int> ans; | |
int n=v.size(); | |
if(n==0) | |
return ans; | |
int a=-1,b=-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
class Solution { | |
public: | |
int majorityElement(vector<int>& a) { | |
int n=a.size(); | |
int freq=1; | |
int no=a[0]; | |
for(int i=1;i<n;i++){ | |
if(a[i]==no) { | |
freq++; |
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 Node { | |
public: | |
int val; | |
int key; | |
Node *pre,*next; | |
Node(int key,int val){ | |
this->key=key; | |
this->val=val; | |
pre=NULL; |
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 WordDictionary { | |
public: | |
class TrieNode{ | |
public: | |
bool leaf; | |
TrieNode *child[26]; | |
TrieNode(){ | |
leaf=0; | |
for(int i=0;i<26;i++) |
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 TrieNode { | |
public: | |
// Initialize your data structure here. | |
bool leaf; | |
TrieNode *child[26]; | |
TrieNode(){ | |
leaf=0; | |
for(int i=0;i<26;i++) | |
child[i]=NULL; |
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
/** | |
* Definition for singly-linked list. | |
* struct ListNode { | |
* int val; | |
* ListNode *next; | |
* ListNode(int x) : val(x), next(NULL) {} | |
* }; | |
*/ | |
class Solution { | |
public: |
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
/** | |
* Definition for singly-linked list. | |
* struct ListNode { | |
* int val; | |
* ListNode *next; | |
* ListNode(int x) : val(x), next(NULL) {} | |
* }; | |
*/ | |
class Solution { | |
public: |
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
// https://leetcode.com/problems/word-ladder/ | |
class Solution { | |
public: | |
struct Node{ | |
int steps; | |
string s; | |
Node(string a,int b){ | |
s=a; | |
steps=b; |
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; | |
int main() | |
{ | |
char s[4]="124"; | |
/* | |
char s[4]="12345"; |
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; | |
int main() | |
{ | |
/* Pointer on Array */ | |
int A[5]={1,2,3,4,5}; | |
int *p=A; |