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
| struct node | |
| { | |
| int info; | |
| struct node *left; | |
| struct node *right; | |
| }; | |
| struct node *common_ancestor(struct node *head, struct node* n1, | |
| struct node *n2) | |
| { |
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 Connection | |
| { | |
| /* generic code ; private */ | |
| /* the interface is public */ | |
| public Connection() { | |
| } | |
| public int connectTo() { | |
| } |
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 Rectagle { | |
| } | |
| class Square extends Rectangle { | |
| } |
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
| abstract class Shape { | |
| } | |
| class Rectangle extends Shape { | |
| } | |
| class Square extends Shape { | |
| } |
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 Person | |
| { | |
| public Person() { | |
| } | |
| public String getName() { | |
| } | |
| public int connectToDB() { | |
| } |
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 Driver | |
| { | |
| public static Connection getConnection() { | |
| } | |
| } | |
| class Person | |
| { | |
| public Person() { | |
| } |
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 Person | |
| { | |
| private String name; | |
| public Person(String name) { | |
| this.name = name; | |
| } | |
| public Person() { | |
| } |
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
| int duplicate(int a[], int n) | |
| { | |
| int sum = 0, num = n - 1; | |
| doulbe ideal_sum = (num * (num + 1)) / 2; | |
| int i; | |
| for (i = 0; i < n; i++) { | |
| sum += a[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
| int missing(int a[], int n) { | |
| double num = n + 1; | |
| double ideal_sum = (num * (num + 1)) / 2; | |
| int sum = 0; | |
| int i; | |
| for (i = 0; i < n; i++) { | |
| sum += a[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
| int get_max_range(int a[], int n, int *start, int *end) | |
| { | |
| int temp_sum = 0, sum = 0, found = -1; | |
| int i, j; | |
| for (i = 0; i < n - 1; i++) { | |
| temp_sum = a[i]; | |
| *start = i; | |
| for (j = i;j < n; j++) { | |
| temp_sum = a[j]; |