Reverse Only Letters | Leetcode 917 | Live coding session 🔥🔥🔥

preview_player
Показать описание
Here is the solution to "Reverse Only Letters" leetcode question. Hope you have a great time going through it.

1) 0:00 Explaining the problem out loud
2) 1:10 Algorithm walkthrough
3) 2:00 Solution approach
4) 4:00 Coding

For discussion/feedback

PS : Please increase the speed to 1.25X
Рекомендации по теме
Комментарии
Автор

Why did you write a function rather than using the Character.isLetter(char a) function. I am asking because you clearly are a good coder, and I want to know if there is a benefit of writing it your own. (covering a edge case for example.)
And thanks for the answer.

thanos-myxq
Автор

//Another alternative solution is :


public String reverseOnlyLetters(String s) {

int low=0;

int high=s.length()-1;
char[] chars=s.toCharArray();
while(low<high){
&&

//swap the characters
char temp=chars[high];
chars[high]=chars[low];
chars[low]=temp;
low++;
high--;
}
else

while(low<high &&
low++;
}
}
else

while(high>low &&
high--;
}
}

}

return new String(chars);
}

praveenj
welcome to shbcf.ru