Leetcode içerisinde bulunan “Add Digits” sorusunun açıklaması ve çözümü. Bu soruda sizi verilen bir tam sayının rakamları toplamı tek hane olana kadar toplayıp geriye döndürmeniz isteniyor.
Leetcode içerisinde bulunan “Determine Color of a Chessboard Square” sorusunun açıklaması ve çözümü. Bu soruda size verilen satranç tahtası üzerindeki karenin beyaz bir kare olup olmadığını bulmanız isteniyor.
Leetcode içerisinde bulunan “Matrix Diagonal Sum” sorusunun açıklaması ve çözümü. Bu soruda sizi jagged array olarak verilen bir matris içerisindeki iki diagonalde bulunan elemanların toplamını bulmanız isteniyor.
Given a square matrix mat, return the sum of the matrix diagonals. Only include the sum of all the elements on the primary diagonal and all the elements on the secondary diagonal that are not part of the primary diagonal.
Example 1:
Input:
mat = [[1,2,3], [4,5,6], [7,8,9]]
Output: 25
Explanation: Diagonals sum: 1 + 5 + 9 + 3 + 7 = 25 Notice that element mat[1][1] = 5 is counted only once.
Example 2:
Input:
mat = [[1,1,1,1], [1,1,1,1], [1,1,1,1], [1,1,1,1]]
Leetcode içerisinde bulunan “Sum of Unique Elements” sorusunun açıklaması ve çözümü. Bu soruda sizi verilen bir tam sayı dizisi içerisindeki unique elemanların toplamını bulmanız isteniyor.
Leetcode içerisinde bulunan “Lowest Common Ancestor of a Binary Search Tree” sorusunun açıklaması ve çözümü. Bu soruda size verilen bir binary search tree içerisinde, verilen iki tane TreeNode’un en aşağıdaki ortak parent’ını bulmanız isteniyor. Bence deneme olarak bunun iterative halini de siz yazabilirsiniz.
“The lowest common ancestor is defined between two nodes p and q as the lowest node in T that has both p and q as descendants (where we allow a node to be a descendant of itself).”
Example 1:
Input: root = [6,2,8,0,4,7,9,null,null,3,5], p = 2, q = 8
Output: 6
Explanation: The LCA of nodes 2 and 8 is 6.
Example 2:
Input: root = [6,2,8,0,4,7,9,null,null,3,5], p = 2, q = 4
Output: 2
Explanation: The LCA of nodes 2 and 4 is 2, since a node can be a descendant of itself according to the LCA definition.
Example 3:
Input: root = [2,1], p = 2, q = 1
Output: 2
Constraints:
The number of nodes in the tree is in the range [2, 105].
-109 <= The number of nodes in the tree is in the range [2, 10^5].
Leetcode içerisinde bulunan “Odd Even Linked List” sorusunun açıklaması ve çözümü. Bu soruda size verilen bir linked list içerisinde, ilk node tek olacak şekilde önce tek index’teki node’ları, ardından çift index’teki node’lar gelecek şekilde düzenlemeniz isteniyor.
Given the head of a singly linked list, group all the nodes with odd indices together followed by the nodes with even indices, and return the reordered list.
The first node is considered odd, and the second node is even, and so on.
Note that the relative order inside both the even and odd groups should remain as it was in the input.
You must solve the problem in O(1) extra space complexity and O(n) time complexity.
LeetCode içerisinde bulunan “Count Negative Numbers in a Sorted Matrix” sorusunun açıklaması ve çözümü. Bu soruda size verilen bir matrix içerisinde kaç adet negatif sayı olduğunu efektif bir şekilde bulmanız isteniyor.
LeetCode içerisinde bulunan “Binary Tree Right Side View” sorusunun açıklaması ve çözümü. Bu soruda size verilen bir binary tree‘nin en sağ tarafındaki node‘ları yukarıdan aşağıda doğru olacak şekilde geri döndürmeniz isteniyor.
Given the root of a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.
Example 1:
Input: root = [1,2,3,null,5,null,4]
Output: [1,3,4]
Example 2:
Input: root = [1,null,3]
Output: [1,3]
Example 3: Input: root = []
Output: []
Constraints:
The number of nodes in the tree is in the range [0, 100].
LeetCode içerisinde bulunan “Set Matrix Zeroes” sorusunun açıklaması ve çözümü. Bu soruda size verilen m * n matrisi içerisinde, eğer bir eleman 0 ise, o elemanın ait olduğu tüm satır ve sütunları da 0 yapmanız isteniyor.