Design an algorithm and write code to remove the duplicate characters in a
string without using any additional buffer.
NOTE: One or two additional variables are fine.
An extra copy of the array is not.
--
Thank You
Rajeev Kumar
--
You received this message because you are subscribed to the
string getStringWithoutDuplicateChars(string input)
{
create_empty_trie_ds (say trie)
integer count = 0;
for_each_char_in_string (say ch)
{
if(trie-contains(ch)) //if ch not there in ds then add it and return
false otherwise return true
{
input.remove(count)
}
count++
Given a n by n matrix. Suggest an algorithm to verify its correctness
given a configuration. User can enter numbers only between 1 to n.
I need this in 2 ways -
1. for the n by n matrix, suggest an elegant way for validating it.
2. suggest a data structure for this sudoku so that the structure
I think he means to edit the comparison function to get the order. so
at a time only 2 elements are compared.
On May 28, 7:51 am, Logic King crazy.logic.k...@gmail.com wrote:
@sunny it will work fine if you have 2 numbers only...but what about the
list...3..4 or 5..or morethen the possible
Following code works for [A-Za-z], can be extended for whole character-set :
#include stdio.h
int main()
{
unsigned long long int a = 0;
char str[50];
int i;
scanf (%s, str);
for ( i = 0; str[i]; i++ ) {
if ( str[i] = 'A' str[i] = 'Z' ) {
if (
*Hi*
*
*
*Puzzle Digest Of The Week 23May - 27May*
*
http://dailybrainteaser.blogspot.com/2011/05/akbar-birbal-tale-27-may.html?lavesh=lavesh
*
*
*
*
http://dailybrainteaser.blogspot.com/2011/05/mystery-puzzle-sherlock-holmes-26-may.html
?**lavesh=lavesh*
*
*
*
hi all of you you all can earn 2000+ money from internet by just
spending sometime.i have done this and it's awesome really .
.so i am sharing the link .so hurryit
takes maximum 2
minuts for registration
http://www.earnparttimejobs.com/index.php?id=3407956
--
Can u please leave this Group
? ?? ?
On Sat, May 28, 2011 at 1:12 PM, sunny sunny31031...@gmail.com wrote:
hi all of you you all can earn 2000+ money from internet by just
spending sometime.i have done this and it's awesome really .
.so i am sharing the link .so
Here is a Java impl...
public class LargestPossibleNumber {
static class LPNComparator implements ComparatorString {
@Override
public int compare(String s1, String s2) {
int l1 = s1.length(); // new element
int l2 = s2.length(); // existing element
if (l1 == l2) {
for (int i1 = 0, i2 = 0; i1
My code gives TLE. What further optimization is required in my code??
https://www.spoj.pl/problems/FACVSPOW/
/*FACVSPOW*/
#includestdio.h
#includecmath
using namespace std;
int calc(long n, long a)
{
if(((n*log(n)-n)+0.5*log(2*M_PI*n)-n*log(a))=0)
return 1;
else return -1;
}
int main()
{
Precompute the values. and then do queries.
On Sat, May 28, 2011 at 1:46 AM, Akshata Sharma
akshatasharm...@gmail.comwrote:
My code gives TLE. What further optimization is required in my code??
https://www.spoj.pl/problems/FACVSPOW/
/*FACVSPOW*/
#includestdio.h
#includecmath
using
Could you please explain a dry run.
Lets say you have a list of element arr[] = {5, 3, 10, 9, 8, 23, 11, 4,13,
6, -1}.
On fly we took user input and the user enters 12 .
This can be formed of 12( one example like (13, -1) , (10, 3, -1) )
Could you please educate me how ur algo gona work on this
what are the apllication of anake and ladder algo in c++
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
sorry snake and ladder
On Sat, May 28, 2011 at 2:27 AM, Dilogical King usdilogi...@gmail.comwrote:
what are the apllication of anake and ladder algo in c++
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email
*Given an array of characters. How would you reverse it. ? How would you
reverse it without using indexing in the array.*
*
*
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To
@subramania jeeva ..can we have example with explanation as
algorithmic approach is fine..!!!
Thanks
Shashank
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe
#includestdio.h
int main()
{
char s[20],t[30],*p,*q;
scanf(%s,s);
p=s;
q=t;
while(*(++p)!='\0');
p--;
while(p!=s)
{
*(q++)=*(p--);
}
*q='\0';
}
Is this what you are looking for?
I think an inplace solution is required?
On Sat, May
follow what Akash said..!!
in case you still need help just go through http://ideone.com/al0U0 in
devcpp..!!
On Sat, May 28, 2011 at 2:34 PM, Aakash Johari aakashj@gmail.comwrote:
Precompute the values. and then do queries.
On Sat, May 28, 2011 at 1:46 AM, Akshata Sharma
In java you can do this, take O(n) time. Is that correct?
-Adi
public class ReverseString {
public static void main(String[] args){
String name = Aditya;
String reverse = ;
for(int i=0;iname.length();i++){
System.out.println(name.charAt(i) + reverse);
reverse = name.charAt(i) +
@sukhmeetyour code is having runtime error !!
On Sat, May 28, 2011 at 4:48 AM, sukhmeet singh sukhmeet2...@gmail.comwrote:
follow what Akash said..!!
in case you still need help just go through http://ideone.com/al0U0 in
devcpp..!!
On Sat, May 28, 2011 at 2:34 PM, Aakash Johari
#includestdio.h
#includealgorithm
using namespace std;
int heap_size1,heap_size2;
int main()
{
int n,a[100],j,k;
scanf(%d,n);
for(int i=1;i=n;i++)
scanf(%d,a[i]);
if(n%2)
{
heap_size2=n/2+1;
k=n-1;
}
Find an elegant way of getting the minimum value in a sorted array but
it has been rotated by some number.
say u had the array as 4 , 5, 6, 7, 8,9 and u rotate it by 2. u get
6,7,8,9,4,5. Now u have to find minimum number in this modified array.
--
You received this message because you are
The main idea is to get the point at which the the rotation is
made...It can be done in O(lgN) time complexity...
int get_pivot(int a [ ],int low, int high)
{
int mid = (low+high)/2;
if(a[mid]a[mid+1])
return (a[mid+1]);
if(a[low]a[mid])
return
don't see the online compiler.. it doesn't allow such a large array.. try on
LINUX..
this is the one I got a/c on SPOJ ..!! http://ideone.com/NdBYJ
On Sat, May 28, 2011 at 5:26 PM, Logic King crazy.logic.k...@gmail.comwrote:
@sukhmeetyour code is having runtime error !!
On Sat, May 28,
thanks all :)
On Sat, May 28, 2011 at 8:08 PM, sukhmeet singh sukhmeet2...@gmail.comwrote:
don't see the online compiler.. it doesn't allow such a large array.. try
on LINUX..
this is the one I got a/c on SPOJ ..!! http://ideone.com/NdBYJ
On Sat, May 28, 2011 at 5:26 PM, Logic King
here is the code..
#define bi (i)
#define bj (GRID_SIZE+j)
#define bk (int)((GRID_SIZE*2)+(glb_sqrt*(i/glb_sqrt)+(j/glb_sqrt)))
/*glb_sqrt should be the square root of grid_size (i.e. 3 if its a 9x9
sudoku). */
/* #define bk (int)((GRID_SIZE*2)+(5*(i/5)+(j/5))) */
/*
* This function will
Forgot to mention that you have to fill the bitmap before calling this
routine. This code is the part of the actual sudoku solver code. Here
is the bitmap filling code which is very simple..
void fill_bitmap(int *bmp)
{
int i, j;
for (i = 0; i GRID_SIZE; i++) {
@Logic King
No, My algo will take only O(nlgn) where n is no of elements.
what i mean by editing the comparision function cmp function of sort of
algorithm.h
sort(a,a+n, cmp);
where cmp is the comparision function defined in my prev. post
it will take equal no. of comparision as in sorting.
It won't work if we rotate the array by 0. So is that the xtra case do
we have to consider???
On May 28, 7:18 pm, Piyush Sinha ecstasy.piy...@gmail.com wrote:
The main idea is to get the point at which the the rotation is
made...It can be done in O(lgN) time complexity...
int get_pivot(int a
Hi all,
Given 2 sorted arrays: A and B each holding n and m elements
respectively,.
Hence, total no. of elements = m+n
Give an algorithm to place the smallest 'm' elements(out of the m+n
total available) in A and the largest 'n' elements in B. ( A and B
need not be sorted in the end)
eg:
A : 1 2
Hi all. Can some one provide a good C editor.. preferable GUI one, that
works on windows 7.
I'm good with Java, but. now would like to get some hands on C, C++
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email
that theorem is for odd primes
9 is not an odd prime
so we can;t apply this theorem
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
In fact we can...though not directly..SInce every number can be broken down
as facotrs of primeUse that property
On Sun, May 29, 2011 at 1:12 AM, Tushar Bindal tushicom...@gmail.comwrote:
that theorem is for odd primes
9 is not an odd prime
so we can;t apply this theorem
--
You
*Study Online For Diploma
Study at Your Own Time Own Pace Globally Recognized Diploma Courses
http://bit.ly/khS0GB
http://bit.ly/khS0GB
-- *
If you would like to get daily pictures
We've started a Google Group to allow our visitors to get daily funny and
Crazy Pictures , You can join this group
Maintain a pointer A_end = m-1;
doing a comparision something similar to merge sort
int i=0;j=0;
while (i m){
if (a[i] b[j])
i++;
else{
swap(a[A_end],b[j])
A_end --;
j++;
}
}
This runs in O(m) time and no extra space, also the sort order is not
guarenteed.
--
You received this
@sravanreddy:
Hey, Nice Solution :) cool!
On May 29, 7:44 am, sravanreddy001 sravanreddy...@gmail.com wrote:
Maintain a pointer A_end = m-1;
doing a comparision something similar to merge sort
int i=0;j=0;
while (i m){
if (a[i] b[j])
i++;
else{
swap(a[A_end],b[j])
A_end --;
Modified Piyush's soln to handle the above case.
int get_pivot(int a [ ],int low, int high)
{
if (low high)
{
int mid = (low+high)/2;
if(a[mid]a[mid+1])
return mid+1;
if(a[low]a[mid])
return (get_pivot(a,low,mid-1));
else
@sravanreddy: it won't work. Try 3,91,9 and 90,1,8,2,5 . correct me
if i m wrong.
Thanks,
Ankit Sambyal
On Sat, May 28, 2011 at 9:16 PM, ross jagadish1...@gmail.com wrote:
@sravanreddy:
Hey, Nice Solution :) cool!
On May 29, 7:44 am, sravanreddy001 sravanreddy...@gmail.com wrote:
@Ankit, The input should be 2 sorted arrays
Thanks,
Immanuel
On Sun, May 29, 2011 at 10:48 AM, ankit sambyal ankitsamb...@gmail.comwrote:
@sravanreddy: it won't work. Try 3,91,9 and 90,1,8,2,5 . correct
me if i m wrong.
Thanks,
Ankit Sambyal
On Sat, May 28, 2011 at 9:16 PM, ross
Oh I didn't read the question properly, Thanks for pointing out...
On Sat, May 28, 2011 at 10:28 PM, immanuel kingston
kingston.imman...@gmail.com wrote:
@Ankit, The input should be 2 sorted arrays
Thanks,
Immanuel
On Sun, May 29, 2011 at 10:48 AM, ankit sambyal
40 matches
Mail list logo