# LeetCode May Challenge – Find the Town Judge – [10. GÜN]

LeetCode’un mayıs ayı için her gün bir programlama sorusu sorduğu “May Challenge”‘ın 10. gün sorusu “Find the Town Judge””ın açıklaması ve çözümü.

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

➡️ Problem açıklaması:

In a town, there are N people labelled from 1 to N. There is a rumor that one of these people is secretly the town judge.

If the town judge exists, then:

– The town judge trusts nobody.

– Everybody (except for the town judge) trusts the town judge.

– There is exactly one person that satisfies properties 1 and 2.

You are given trust, an array of pairs trust[i] = [a, b] representing that the person labelled a trusts the person labelled b.

If the town judge exists and can be identified, return the label of the town judge. Otherwise, return -1.

Example 1:

Input: N = 2, trust = [[1,2]]

Output: 2

Example 2:

Input: N = 3, trust = [[1,3],[2,3]]

Output: 3

Example 3:

Input: N = 3, trust = [[1,3],[2,3],[3,1]]

Output: -1

Example 4:

Input: N = 3, trust = [[1,2],[2,3]]

Output: -1

Example 5:

Input: N = 4, trust = [[1,3],[1,4],[2,3],[2,4],[4,3]]

Output: 3

# 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 – Check If It Is a Straight Line – [8. GÜN]

LeetCode’un mayıs ayı için her gün bir programlama sorusu sorduğu “May Challenge”‘ın sekizinci gün sorusu “Check If It Is a Straight Line””ın açıklaması ve çözümü.

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

➡️ Problem açıklaması:

You are given an array coordinates, coordinates[i] = [x, y], where [x, y] represents the coordinate of a point. Check if these points make a straight line in the XY plane.

Input: coordinates = [[1,2],[2,3],[3,4],[4,5],[5,6],[6,7]]

Output: true

Input: coordinates = [[1,1],[2,2],[3,4],[4,5],[5,6],[7,7]]

Output: false

# LeetCode May Challenge – Majority Element – [Google ve Baidu Mülakat Sorusu] 6. GÜN

LeetCode’un mayıs ayı için her gün bir programlama sorusu sorduğu “May Challenge”‘ın altıncı gün sorusu “Majority Element””in açıklaması ve çözümü. LeetCode’a göre Google ve Baidu mülakatlarında sorulmuş sorulardan biri.

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

➡️ Problem açıklaması:

Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.

You may assume that the array is non-empty and the majority element always exist in the array.

Example 1:

Input: [3,2,3]

Output: 3

Example 2:

Input: [2,2,1,1,1,2,2]

Output: 2

# LeetCode May Challenge – First Unique Character in a String – [Amazon Mülakat Sorusu] 5. GÜN

LeetCode’un mayıs ayı için her gün bir programlama sorusu sorduğu “May Challenge”‘ın beşinci gün sorusu “First Unique Character in a String””in açıklaması ve çözümü. LeetCode’a göre Amazon mülakatlarında sorulmuş sorulardan biri.

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

➡️ Problem açıklaması:

Given a string, find the first non-repeating character in it and return it’s index. If it doesn’t exist, return -1.

Examples:

s = “leetcode” return 0.

s = “loveleetcode”, return 2.

Note: You may assume the string contain only lowercase letters.

# LeetCode May Challenge – Number Complement – [Cloudera Mülakat Sorusu] 4. GÜN

LeetCode’un mayıs ayı için her gün bir programlama sorusu sorduğu “May Challenge”‘ın dördüncü gün sorusu “Number Complement””ın açıklaması ve çözümü. LeetCode’a göre Cloudera mülakatlarında sorular sorulardan biridir.

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

➡️ Problem açıklaması:

Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation.

Example 1:

Input: 5

Output: 2

Explanation: The binary representation of 5 is 101 (no leading zero bits), and its complement is 010. So you need to output 2.

Example 2:

Input: 1

Output: 0

Explanation: The binary representation of 1 is 1 (no leading zero bits), and its complement is 0. So you need to output 0.

Note: The given integer is guaranteed to fit within the range of a 32-bit signed integer. You could assume no leading zero bit in the integer’s binary representation.

# LeetCode May Challenge – Ransom Note – [Microsoft Mülakat Sorusu] 3. GÜN

LeetCode’un mayıs ayı için her gün bir programlama sorusu sorduğu “May Challenge”‘ın üçüncü gün sorusu “Ransom Note””un açıklaması ve çözümü. Leetcode’a göre bu soru Microsoft mülakatlarında sorulan sorulardan biriymiş. #LeetCode #Programlama #Microsoft

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

➡️ Problem açıklaması:

Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note can be constructed from the magazines ; otherwise, it will return false.

Each letter in the magazine string can only be used once in your ransom note.

Note: You may assume that both strings contain only lowercase letters.

canConstruct(“a”, “b”) — false

canConstruct(“aa”, “ab”) — false

canConstruct(“aa”, “aab”) — true

# LeetCode May Challenge – Jewels and Stones – [Amazon ve Adobe Mülakat Sorusu] 2. GÜN

LeetCode’un mayıs ayı için her gün bir programlama sorusu sorduğu “May Challenge”‘ın ikinci gün sorusu “Jewels and Stones””un açıklaması ve çözümü. LeetCode’a göre bu soru Amazon ve Adobe mülakatlarında sorular sorulardan biri.

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

➡️ Problem açıklaması:

You’re given strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in S is a type of stone you have. You want to know how many of the stones you have are also jewels.

The letters in J are guaranteed distinct, and all characters in J and S are letters. Letters are case sensitive, so “a” is considered a different type of stone from “A”.

Example 1:

Input: J = “aA”, S = “aAAbbbb”

Output: 3

Example 2:

Input: J = “z”, S = “ZZ”

Output: 0

Note: S and J will consist of letters and have length at most 50. The characters in J are distinct.

# 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.