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
Node* Reverse(Node *head) | |
{ | |
Node* trail=0; | |
while (head){ | |
Node* next= head->next; | |
head->next = trail; | |
trail=head; | |
head=next; | |
} | |
return trail; |
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
void Inorder(node *root) { | |
if (root) { | |
Inorder(root->left); | |
cout << to_string(root->data) + " "; | |
Inorder(root->right); | |
} | |
} |
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
int main() { | |
/* Enter your code here. Read input from STDIN. Print output to STDOUT */ | |
int cases, x; | |
//first, we find how many numbers we have, we use scanf on the input from STDIN, to return the number | |
//of cases we have to cases variable | |
scanf("%u", &cases); | |
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
public int lengthOfLongestSubstring(String s) { | |
if(s==null || s.length()==0){ | |
return 0; | |
} | |
HashSet<Character> set = new HashSet<Character>(); | |
int max=0; | |
int i=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
public class MyStack<T extends Comparable<T>>{ | |
private static class StackNode<T extends Comparable<T>> { | |
private Comparable<T> data; | |
private StackNode<T> next; | |
public StackNode(Comparable<T> item){ | |
this.data =item; | |
} |
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
public boolean canFinish(int numCourses, int[][] prerequisites) { | |
if(prerequisites == null){ | |
throw new IllegalArgumentException("Invalid Prerequisites"); | |
} | |
int p_len = prerequisites.length; | |
if(p_len == 0||numCourses == 0){ | |
return true; | |
} |
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
# Lavar Ball is looking for scholarships to help pay for school. | |
# He has 2 lists, A and B. | |
# A is a cache of Lavar's scholarships as an array of primary keys. | |
# B is an array of scholarship objects matching Lavar's profile. | |
# Lavar needs to sort the objects in B based on the PKs of A, to get a new B (B_2). | |
# Lavar needs it done in less than O(n^2) time so he doesn't get bored and starts browsing Reddit. | |
# e.g. | |
A = [3,139,47] # arbitrary order | |
B = [{pk:139,name:'Scholarship X'},{pk:47,name:'Scholarship Y'},{pk:3,name:'Scholarship Z'}] |
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
// src/main.ts | |
import { enableProdMode } from '@angular/core'; | |
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; | |
import { AppModule } from './app/app.module'; | |
import { environment } from './environments/environment'; | |
if (environment.production) { | |
enableProdMode(); | |
} |
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
<iframe src="//www.youtube.com/embed/_youtube_id_" width="560" height="315" frameborder="0" | |
allowfullscreen="allowfullscreen"> | |
</iframe> | |
<iframe class="i-amphtml-fill-content" style="z-index: 0; width: 500px; height: 200px;" | |
src="https://open.spotify.com/embed/show/0m74ZmCPgjvp5WGOMg3P9C#amp=1" | |
name="amp_iframe0" width="src=" frameborder="0" sandbox="allow-scripts allow-same-origin"> | |
</iframe> |
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
# use this if you want to delete a specific number of entries | |
# https://stackoverflow.com/questions/13248593/django-database-delete-specific-number-of-entries | |
HomeImage.objects.filter(pk__in=HomeImage.objects.filter(ImageVectors={}).values_list('pk')[:5000])#.delete() |
OlderNewer