LeetCode içerisinde bulunan “Base 7” sorusunun açıklaması ve çözümü. Bu soruda size verilen 32-bit integer değerin 7 tabanında gösterimini geriye döndürmeniz isteniyor.
HackerRank içerisinde bulunan “Super Reduced String” sorusunun açıklaması ve çözümü. Bu soruda size verilen bir string‘in içerisinde, yan yana olan aynı karakterlerin silinerek elde edilebilecek son string’i bulmanız isteniyor.
Reduce a string of lowercase characters in range ascii[‘a’..’z’]by doing a series of operations. In each operation, select a pair of adjacent letters that match, and delete them.
Delete as many characters as possible using this method and return the resulting string. If the final string is empty, return Empty String
Example.
s = “aab”
aab shortens to b in one operation: remove the adjacent a characters.
s = “abba”
Remove the two ‘b’ characters leaving ‘aa’. Remove the two ‘a’ characters to leave ”. Return ‘Empty String’.
Function Description
Complete the superReducedString function in the editor below.
superReducedString has the following parameter(s):
string s: a string to reduce
Returns
string: the reduced string or Empty String
Sample Input 0
aaabccddd
Sample Output 0
abd
Explanation 0
Perform the following sequence of operations to get the final string:
LeetCode içerisinde bulunan “Reverse Vowels of a String” sorusunun açıklaması ve çözümü. Bu soruda size verilen bir string içerisindeki ünlü harfleri tersten yazdırmanız isteniyor.
HackerRank içerisinde bulunan “Grading Students” sorusunun açıklaması ve çözümü. Bu soruda size verilen sınav sonuçlarını, aşağıda yazılan kurallara göre yuvarlamanız isteniyor.
HackerRank içerisinde bulunan “CamelCase” sorusunun açıklaması ve çözümü. Bu soruda size camelCase olarak yazılmış bir string’in içerisinde kaç adet kelime olduğunu bulmanız isteniyor.
LeetCode içerisinde bulunan “Keyboard Row” sorusunun açıklaması ve çözümü. Bu soruda size verilen bir string dizisi içerisinde, Amerikan klavyesi üzerinde aynı satırdaki harflerden oluşan string’leri geri döndürmeniz isteniyor.
Given an array of strings words, return the words that can be typed using letters of the alphabet on only one row of American keyboard like the image below.
In the American keyboard:
the first row consists of the characters “qwertyuiop”,
the second row consists of the characters “asdfghjkl”, and
the third row consists of the characters “zxcvbnm”.
Example 1:
Input: words = [“Hello”,”Alaska”,”Dad”,”Peace”]
Output: [“Alaska”,”Dad”]
Example 2:
Input: words = [“omk”]
Output: []
Example 3:
Input: words = [“adsdf”,”sfd”]
Output: [“adsdf”,”sfd”]
Constraints: 1 <= words.length <= 20
1 <= words[i].length <= 100
words[i] consists of English letters (both lowercase and uppercase).
HackerRank içerisinde bulunan “Fibonacci Modified” sorusunun açıklaması ve çözümü. Bu soruda fibonacci serisinin değiştirilmiş hali olarak, bir önceki sayının kendisi değil de karesinin toplamı şeklinde çözüm bulmanız isteniyor.
Implement a modified Fibonacci sequence using the following definition:
t(i + 2) = t(i) + t(i + 2)^2
Given three integers, t1, t2, and n, compute and print the nth term of a modified Fibonacci sequence.
Function Description
Complete the fibonacciModified function in the editor below. It must return the nth number in the sequence.
fibonacciModified has the following parameter(s):
int t1: an integer
int t2: an integer
int n: the iteration to report
Returns
int: the nth number in the sequence
Note: The value of t[n] may far exceed the range of a 64-bit integer. Many submission languages have libraries that can handle such large results but, for those that don’t (e.g., C++), you will need to compensate for the size of the result.
LeetCode içerisinde bulunan “Power of Four” sorusunun açıklaması ve çözümü. Bu soruda size verilen 32-bit signed bir tam sayının 4’ün tam kuvveti olup olmadığını bulmanız isteniyor.
LeetCode içerisinde bulunan “Reverse Bits” sorusunun açıklaması ve çözümü. Soruda size verilen 32-bit unsigned bir tam sayının bitlerini tersine çevirmeniz isteniyor.
Note that in some languages such as Java, there is no unsigned integer type. In this case, both input and output will be given as a signed integer type. They should not affect your implementation, as the integer’s internal binary representation is the same, whether it is signed or unsigned. In Java, the compiler represents the signed integers using 2’s complement notation. Therefore, in Example 2 above, the input represents the signed integer -3 and the output represents the signed integer -1073741825.
Follow up:
If this function is called many times, how would you optimize it?
Explanation: The input binary string 00000010100101000001111010011100 represents the unsigned integer 43261596, so return 964176192 which its binary representation is 00111001011110000010100101000000.
Explanation: The input binary string 11111111111111111111111111111101 represents the unsigned integer 4294967293, so return 3221225471 which its binary representation is 10111111111111111111111111111111.
HackerRank içerisinde bulunan “Extra Long Factorials” sorusunun açıklaması ve çözümü. Bu soruda size verilen bir tam sayının faktöriyelini bulmanız isteniyor. Bazı inputlar için faktöriyel 64-bit tam sayıyı aşabilir, bu yüzden daha büyük bir tam sayı tipi kullanmanız gerekiyor.
The factorial of the integer n, written n!, is defined as:
n! = n * (n – 1) * (n – 2) * … * 3 * 2 * 1
Function Description
Complete the extraLongFactorials function in the editor below. It should print the result and return.
extraLongFactorials has the following parameter(s):
n: an integer
Note: Factorials of n biggerThan 20 can’t be stored even in a 64-bit long long variable. Big integers must be used for such calculations. Languages like Java, Python, Ruby etc. can handle big integers, but we need to write additional code in C/C++ to handle huge values.
We recommend solving this challenge using BigIntegers.