This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
UBER | |
Description of Question | |
The goal is to write a function which takes a | |
list of string items and returns a list containing | |
unique items sorted based on their frequency in descending order | |
Example: | |
input = I -> am -> happy -> so -> I -> sing -> happy -> happy -> songs | |
output = happy -> I -> am -> so -> sing -> songs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* In this chapter, you’ll learn about the Big O notation for the different levels of scalability in two dimensions: | |
* • Execution time. | |
* • Memory usage. | |
*/ | |
fun main() {} | |
/** Constant time * | |
* A constant time algorithm is one that has the same running time regardless of the size of the input. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This question is asked by Amazon. Given a string representing the sequence of moves a robot vacuum makes, | |
* return whether or not it will return to its original position. The string will only contain L, R, U, and D characters, | |
* representing left, right, up, and down respectively. | |
* | |
* Ex: Given the following strings... | |
* | |
* "LR", return true | |
* "URURD", return false | |
* "RUULLDRD", return true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This question is asked by Google. Given a string, reverse all of its characters and return the resulting string. | |
* Ex: Given the following strings... | |
* “Cat”, return “taC” | |
* “The Daily Byte”, return "etyB yliaD ehT” | |
* “civic”, return “civic” | |
*/ | |
fun main() { | |
val stringValue = readLine()!! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This question is asked by Facebook. Given a string, return whether or not it forms a | |
* palindrome ignoring case and non-alphabetical characters. | |
* | |
* Note: a palindrome is a sequence of characters that reads the same forwards and backwards. | |
* | |
* Ex: Given the following strings... | |
* "level", return true | |
* "algorithm", return false | |
* "A man, a plan, a canal: Panama.", return true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This question is asked by Google. Given a string, return whether or not it uses capitalization correctly. | |
* A string correctly uses capitalization if all letters are capitalized, no letters are capitalized, or only the first letter is capitalized. | |
* Ex: Given the following strings... | |
* | |
* "USA", return true | |
* "Calvin", return true | |
* "compUter", return false | |
* "coding", return true | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This question is asked by Apple. Given two binary strings (strings containing only 1s and 0s) return their sum (also as a binary string). | |
* Note: neither binary string will contain leading 0s unless the string itself is 0. | |
* Ex: Given the following binary strings... | |
* | |
* "100" + "1", return "101" | |
* "11" + "1", return "100" | |
* "1" + "0", return "1" | |
* | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct node { | |
int value; | |
struct node *next; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data class Node(var value: String, var next: Node? = null) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LinkedList { | |
private var head: Node? = null | |
private var tail: Node? = null | |
private var size = 0 | |
fun isEmpty(): Boolean { | |
return size == 0 | |
} | |
} |
OlderNewer