tejaswi.yvs
BAN USERHmm, I'd say count and color can be implemented using slight tweaks to the floodfill algorithm. I'm not sure how rotation and scaling are achieved.
 tejaswi.yvs April 30, 2014If the string was originally sorted, maybe binary search, find the first occurrence of the char and substitute.
Still, the worst case would be O(n) if all the characters in the string are the same as has been pointed out by others.
Sort array first and swap pairs of numbers?
So 7 6 5 4 3 2 1 becomes  7 5 6 3 4 1 2
n^2 algorithm is straight forward I think. I don't know if I can come up with a DP one. Incidentally, does anyone know if brute force is good enough for a phone interview?
private void findMinSequenceWithSum(int[] array, int input) {
Tuple<int, int> minRange = null;
for (int i = 0; i < array.Length; i++) {
int sum = 0;
for (int j = i; j < array.Length; j++) {
sum = sum + array[j];
if (sum > input) {
Tuple<int, int> range = new Tuple<int, int>(i, j);
if (this.isRangeSmaller(range, minRange)) {
minRange = range;
}
break;
}
}
}
}
private bool isRangeSmaller(Tuple<int, int> source, Tuple<int, int> target) {
if (source == null) {
return false;
}
if (target == null) {
return true;
}
return (source.Item2  source.Item1 < target.Item2  target.Item1);
}

tejaswi.yvs
April 20, 2014 I wonder if the question is just how printf takes a format string, a list of args, constructs a string from it and then writes it to console. I atleast would like to know the answer to this though.
 tejaswi.yvs March 04, 2014Open Chat in New Window
Not sure I understand what you mean by "edges don't intersect and they seem ordered". Can you clarify? What happens for example in a complete graph of 4 nodes?
 tejaswi.yvs May 19, 2014