Presto is a distributed big data SQL engine initially developed by Facebook and later open-sourced and being led by the community. The last article Presto SQL: Types of Joins covers the fundamentals of join operators available in Presto and how they can be used in SQL queries. With that knowledge, you can now learn the internals of Presto and how it executes join operations internally. This article presents how Presto executes join operations and the algorithms used to join tables.
Showing posts with label Algorithms. Show all posts
Showing posts with label Algorithms. Show all posts
Determine if a String has all Unique Characters
Question: Implement an algorithm to determine if a string has all unique characters.
Example:
Break Down:
Let's write a class named TestUniqueness which has a method isUnique which can be called from the main method as given below:
Example:
The String "Hello" has two "l"s. Therefore, it does not have all unique characters. On the other hand, if you consider the String "World", it is formed using all unique characters.
Break Down:
Let's write a class named TestUniqueness which has a method isUnique which can be called from the main method as given below:
public class TestUniqueness {
public static void main(String[] args) {
System.out.println(isUnique("hello"));
System.out.println(isUnique("world"));
}
public static boolean isUnique(String text) {
return false;
}
}Of course, you can write a fancy code to read user input and feed them to an
isUnique method. However, to keep the code clean and simple, I am calling the static method isUnique and immediately print the response. The isUnique method returns false all the times. In the following section, we are going to implement the algorithm for the isUnique method.
Subscribe to:
Posts (Atom)
