CODES
some learning from problems.
CODES
some learning from problems.
Showing posts with label
C
.
Show all posts
Showing posts with label
C
.
Show all posts
Friday, 14 September 2012
Sort an Array of 0 1& 2 in one pass
›
G iven an array int a[] = {0, 1, 1 ,0, 2, 2, 1, 0 ,1, 2, 1,0 } to be converted into {0, 0, 0, 0, 1, 1, 1, 1, 1 ,2 ,2 ,2} inplace a...
Wednesday, 4 July 2012
Consider you have a grid of size m x n. There are stones placed randomly in some of the squares of this grid. Design a way to find out minimum rectangular area which covers all the stones in this grid.
›
Smallest Rectangle Input :(place 1 as rock other wise 0) 5 4 0 0 0 0 0 1 0 0 0 0 0 1 1 0 0 0 0 0 0 0 Output: (1,0), (1,3), (3,0),...
The character 'a' to 'z' are encoded as 1 - 26. Given a string of digits, compute the number of valid decodings of the string. For example, both 'aa' and 'k' can be encoded as '11'. Hence num_valid_encodings('11') = 2.
›
recursive #include <stdio.h> #include <string.h> int count_decode(char S[10],int n) { int x1=S[n-1]-'0',x2...
2 comments:
atoi is a function in the C programming language that converts a string into an integer numerical representation. atoi stands for ASCII to integer. It is included in the C standard library header file stdlib.h. Its prototype is as follows:
›
atoi : ASCII to integer //INPUT : 24 83 0 2 //OUTPUT : 24 83 0 2 #include<stdio.h> #include<string.h> int ...
String Masking : Given a string"S" and we have to remove a an occurance of a small string "M" from there.
›
Input: KUMAR UM Output: KAR #include<stdio.h> #include<string.h> int str_com(char K[20],int i,int m,char M[10]) {...
Home
View web version