# LeetCode Çözümleri – 69. Sqrt(x)

LeetCode içerisinde bulunan “Sqrt(x)”‘ sorusunun açıklaması ve çözümü. Bu soruda tamsayı bir parametre alan metodunuzdan geriye o sayının karekökünün tam sayı halini döndürmenizi istiyor. Tabi bunun için hali hazırda kullandığınız programlama dilinde var olan sqrt() gibi metodları kullanmamanız gerekmekte.

🔥 LeetCode 69. Sqrt(x): https://leetcode.com/problems/sqrtx/

➡️ Problem açıklaması:

Implement int sqrt(int x).

Compute and return the square root of x, where x is guaranteed to be a non-negative integer.

Since the return type is an integer, the decimal digits are truncated and only the integer part of the result is returned.

Example 1:

Input: 4

Output: 2

Example 2:

Input: 8

Output: 2

Explanation: The square root of 8 is 2.82842…, and since the decimal part is truncated, 2 is returned.

# LeetCode Çözümleri – 38. Count And Say

LeetCode içerisinde bulunan “Count And Say”‘ sorusunun açıklaması ve çözümü.

🔥 LeetCode 38. Count And Say: https://leetcode.com/problems/count-and-say/

🔥 Look-and-say sequence: https://en.wikipedia.org/wiki/Look-and-say_sequence

➡️ Problem açıklaması:

The count-and-say sequence is the sequence of integers with the first five terms as following:

1. 1

2. 11

3. 21

4. 1211

5. 111221

1 is read off as “one 1” or 11.

11 is read off as “two 1s” or 21.

21 is read off as “one 2, then one 1” or 1211.

Given an integer n where 1 ≤ n ≤ 30, generate the nth term of the count-and-say sequence. You can do so recursively, in other words from the previous member read off the digits, counting the number of digits in groups of the same digit.

☢️ Note: Each term of the sequence of integers will be represented as a string.

Example 1:

Input: 1

Output: “1”

Explanation: This is the base case.

Example 2:

Input: 4

Output: “1211”

Explanation:

For n = 3 the term was “21” in which we have two groups “2” and “1”, “2” can be read as “12” which means frequency = 1 and value = 2, the same way “1” is read as “11”, so the answer is the concatenation of “12” and “11” which is “1211”.

# LeetCode May Challenge – Valid Perfect Square – [9. GÜN]

LeetCode’un mayıs ayı için her gün bir programlama sorusu sorduğu “May Challenge”‘ın 9. gün sorusu “Valid Perfect Square””in açıklaması ve çözümü.

🔥 LeetCode May Challenge: https://leetcode.com/explore/featured/card/may-leetcoding-challenge

➡️ Problem açıklaması:

Given a positive integer num, write a function which returns True if num is a perfect square else False.

☢️ Note: DO NOT use any built-in library function such as sqrt.

Example 1:

Input: 16

Output: true

Example 2:

Input: 14

Output: false

# LeetCode May Challenge – First Bad Version 1. GÜN – [Facebook Mülakat Sorusu]

LeetCode’un mayıs ayı için her gün bir programlama sorusu sorduğu “May Challenge”‘ın ilk gün sorusu “First Bad Version”‘ın açıklaması ve çözümü. LeetCode’a göre bu soru Facebook’un mülakatlarında sormuş olduğu sorulardan biriymiş.

🔥 LeetCode May Challenge: https://leetcode.com/explore/featured/card/may-leetcoding-challenge

✅ Problem açıklaması:

You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous version, all the versions after a bad version are also bad.

Suppose you have n versions [1, 2, …, n] and you want to find out the first bad one, which causes all the following ones to be bad.

You are given an API bool isBadVersion(version) which will return whether version is bad. Implement a function to find the first bad version. You should minimize the number of calls to the API.

Example: Given n = 5, and version = 4 is the first bad version.