Skip to content

Instantly share code, notes, and snippets.

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;
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++;
class Node {
public:
int val;
int key;
Node *pre,*next;
Node(int key,int val){
this->key=key;
this->val=val;
pre=NULL;
class WordDictionary {
public:
class TrieNode{
public:
bool leaf;
TrieNode *child[26];
TrieNode(){
leaf=0;
for(int i=0;i<26;i++)
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;
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
// https://leetcode.com/problems/word-ladder/
class Solution {
public:
struct Node{
int steps;
string s;
Node(string a,int b){
s=a;
steps=b;
#include <iostream>
using namespace std;
int main()
{
char s[4]="124";
/*
char s[4]="12345";
#include<iostream>
using namespace std;
int main()
{
/* Pointer on Array */
int A[5]={1,2,3,4,5};
int *p=A;