JIT Derleyicisine Giriş – Constant folding ve Function folding

.NET içerisinde Common Language Runtime’ın bir parçası olan JIT compiler‘ın sağladığı özelliklerden olan “constant folding” ve “function folding” kavramlarına baktık bu videoda.

Kaynaklar:

https://en.wikipedia.org/wiki/Constant_folding

https://en.wikipedia.org/wiki/Fold_(higher-order_function)

https://sharplab.io/

https://godbolt.org/

Leetcode Çözümleri | Valid Palindrome II

Leetcode içerisinde bulunan “Valid Palindrome II” sorusunun açıklaması ve çözümü. Bu soruda size verilen bir string için, en fazla 1 karakter silerek palindrom yapılıp yapılamayacağı soruluyor. En fazla denildiği için hiç karakter silmeyebilirsiniz tabi.

➡️ Leetcode Valid Palindrome II: https://leetcode.com/problems/valid-palindrome-ii/

➡️ Problem açıklaması:

Given a string s, return true if the s can be palindrome after deleting at most one character from it.

Example 1:

Input: s = “aba”

Output: true

Example 2:

Input: s = “abca”

Output: true

Explanation: You could delete the character ‘c’.

Example 3:

Input: s = “abc”

Output: false

Constraints:

1 <= s.length <= 10^5

s consists of lowercase English letters.

Leetcode Çözümleri | Binary Search

Leetcode içerisinde bulunan “Binary Search” sorusunun açıklaması ve çözümü. Bu soruda size artan sırada verilen bir tam sayı dizisinde, O(log*n) çalışma zamanında olan bir algoritma ile verilen bir tam sayının index’ini, bu tam sayı dizide yoksa -1 döndürmeniz isteniyor. Kısaca binary search algoritmasını implement etmeniz isteniyor.

➡️ LeetCode 704. Binary Search: https://leetcode.com/problems/binary-search/

➡️ Problem açıklaması:

Given an array of integers nums which is sorted in ascending order, and an integer target, write a function to search target in nums. If target exists, then return its index. Otherwise, return -1.

You must write an algorithm with O(log n) runtime complexity.

Example 1:

Input: nums = [-1,0,3,5,9,12], target = 9

Output: 4

Explanation: 9 exists in nums and its index is 4

Example 2:

Input: nums = [-1,0,3,5,9,12], target = 2

Output: -1

Explanation: 2 does not exist in nums so return -1

Constraints:

1 <= nums.length <= 10^4

-10^4 < nums[i], target < 10^4

All the integers in nums are unique.

nums is sorted in ascending order.