SRB
BAN USERWhere ever you go(top 15 or top 5) and what you did, its does not matter. Matter is how you deal with situation. I have not told about myself, and don't want to do it here as well. And don't think that everyone lesser than you.
Keep all your credit or achieviement in your pocket. From your response its reflecting how dirty mind you have.
I was silent from long days, and some stupid ppl keep on using slangs here ... what you say over this ? Is it there genetic problem ? Is this forum for this ?
<pre lang="" line="1" title="CodeMonkey98982" class="run-this">/* The class name doesn't have to be Main, as long as the class is not public. */
class Main
{
public static void main (String[] args) throws java.lang.Exception
{
java.io.BufferedReader r = new java.io.BufferedReader (new java.io.InputStreamReader (System.in));
String s;
while (!(s=r.readLine()).startsWith("42")) System.out.println(s);
}
}
</pre><pre title="CodeMonkey98982" input="yes">
</pre>
<pre lang="" line="1" title="CodeMonkey54649" class="run-this">/* The class name doesn't have to be Main, as long as the class is not public. */
class Main
{
public static void main (String[] args) throws java.lang.Exception
{
java.io.BufferedReader r = new java.io.BufferedReader (new java.io.InputStreamReader (System.in));
String s;
while (!(s=r.readLine()).startsWith("42")) System.out.println(s);
}
}
</pre><pre title="CodeMonkey54649" input="yes">
</pre>
1. Sort Elements of Array.
2. SET1 & SET2 contains zero elements.
3. For each pairs(e.g. e1, e2) of element from beginning of sorted array do following
a. SUM1 = SUMMATION(SET1) + e1;
b. SUM2 = SUMMATION(SET2) + e2;
c. SUM3 = SUMMATION(SET1) + e2;
d. SUM4 = SUMMATION(SET2) + e1;
e. if(MOD(SUM1, SUM2) < MOD(SUM3, SUM4))
Add e1 to SET1 & e2 to SET2
else
Add e2 to SET1 & e1 to SET2
Result: SET1 & SET2 contains final elements.
Time Complexity: N*log(N) + (N/2)
char *increment(char *str)
{
int k;
int add = 1;
int l = strlen(str);
if (l == 0) return NULL;
while(True && l>0)
{
k = char2int(str[l-1]);
k = k + add;
str[l-1] = int2char(k%10); //Update the Number
add = k/10;
if(add == 0) //If no carry over
break;
else
{
l--;
}
}
if(l==0 && add !=0)
{
char *new_str = (char*)malloc(sizeof(char)+1);
new_str[0] = int2char(add);
for(int i=0;i<l; i++)
{
new_str[i+1] = str[i];
}
return new_str;
}
return str;
}
int distance(int Arr[], int arr_size, int num1, int num2)
{
int dis = arr_size+1;
for(int i = 0; i<arr_size; i++)
{
if(Arr[i] == num1)
{
for(int j = 0; j<arr_size; j++)
{
if(Arr[j] == num2)
{
n_dis = MOD(i, j);
dis = min(dis, n_dis);
}
}
}
}
return dis;
}
Order = N Square
- SRB June 22, 2011void ReverseWordsInString(char *str)
{
int l = 0;
if(!str)
{
printf("NULL String");
return;
}
l = strlen(str);// O(N)
int s = 0; //Starting index of string
inr e = l-1; //End index of string
char t_ch;
//I: the bus
while(s<e) //Reverse String // O(N)
{
//Swap Sring charcter
t_ch = *(str + s);
*(str + s) = *(str + e);
*(str + e) = t_ch;
s++;
e--;
}
//O: sub eht
// bus the
//Reverse words of string
int space = 1;
int i = 0;
s = 0; e = 0;
int t_s, t_e;
for(i=0; i<l; i++) // O(N)
{
if(str[i] == ' ')//Check for while space
{
if(!space)//Check for eleminating multiple spaces
{
e = i-1;
t_s = s;
t_e = e;
while(t_s<t_e)//reverse word
{
t_ch = *(str + s_t);
*(str + s_t) = *(str + e_t);
*(str + e_t) = t_ch;
t_s++;
t_e--;
}
space = 1;
}
s = i+1;
}
else
{
space = 0;
}
}
printf("String after word reverse: %s", str);
return;
}
Overloading: Function with same name but different prototype.
E.g: int sum(int, int);
float sum(float, float);
Overriding: Function with same name and same prototype.
Base class function given higher priority than Derived Class function.
E.g:
classs Base
{
public:
int sum(int,int);
}
class Derived: public base
{
public:
int sum(int,int);
}
void DeleteBSTree (Node *Root)
{
Node *Temp, *TRight;
Temp = Roor;
while(Temp)// Go to the Right most node
{
TRight = Temp;
Temp = Temp->Right;
}
while(Root)
{
if(Root->Left) //Convert to LL
TRight->Right = Root->Left;
DeleteNode = Root;
Root = Root->Right;
Free(DeleteNode)
}
}
Here is the Single Comparision Code:
int BinSearch(int A[], int n , int key )
{
int s = 0;
int e = n-1;
int m;
while(s<e)
{
m = (s+e)/2;
if(key<=A[m])
{
e = m;
}
else
{
s = m+1;
}
}
if(A[e] == key)
{
printf("Key %d present at location %d\n", key, e);
return e;
}
else
{
printf("Key Not Present in List\n");
return -1;
}
}
Below programm written with following Basic Idea:
Take any size of sub-matrix from the input 2D matrix, the smallest element is left top one.
int r, c; // r:row, c:column
int smallest[2][r*c];
int index = 0
int find_Kth_Min(int MAT[][], int r, int c, int kth_min)
{
int i, j, k_x, k_y;
if(kth_min == 0)
return MAT[0][0];
if(kth_min == r*c)
return MAT[r][c];
if(kth_min < 0 || kth_min > r*c)
{
printf("Invalid input");
return;
}
for(i = 0; i<2; i++)
for(j = 0; j<r+c; j++)
smallest[i][j] = -1;
//Keeping in index of smallest element
smallest[0][0] = 0;
smallest[1][0] = 0;
index = 1;
while(kth_min)
{
find_smallest(smallest, &k_x, &k_y, MAT);
kth_min--;
}
return MAT[k_x][k_y];
}
void find_smallest(int smallest[][], int *k_x, int *k_y, int MAT[][])
{
min = 9999999, p;
for(int i=0; i<index; i++)
if(MAT[smallest[0][i]][smallest[1][i]]<min)
{
min = MAT[smallest[0][i]][smallest[1][i]];
*k_x = smallest[0][i];
*k_y = smallest[1][i];
p = i;
}
smallest[0][p] = k_x+1;
smallest[1][p] = k_y;
smallest[0][index] = k_x;
smallest[1][index] = k_y+1;
index++;
return;
}
Time Complexity: O(K*3)
- SRB February 13, 2011char *pattern_convertion(char *str)
{
char *ret = NULL;
int l = strlen(str);
if(l == 0) return NULL;
if((ret = (char *)malloc(l*sizeof(char))) == NULL) return NULL;
int c = 0, i,j;
for(i = 0; i<l; i++)
{
for(j = 0; j<i+1; j++, c++)
ret[c] = str[i];
}
for(i = l-1; i>=0; i--)
{
for(j = 0; j<=l; j--, c++)
ret[c] = str[i];
}
ret[c] = '\0';
return ret;
}
Where you find claiming for genius ?
- SRB August 26, 2011There are other way to stop such crap reply, and using slangs for this is not the best way.