Как стать автором
Обновить
4
0
Sergey Leschev ✓⃝ @Leschev

System Architect | Team Lead | CTO

Отправить сообщение

LeetCode, Hard++ (Acceptance 24%, Latest): 2867. Count Valid Paths in a Tree. DFS. O(n). Swift

Уровень сложностиСложный
Время на прочтение2 мин
Количество просмотров1.7K

The intuition is to employ a depth-first search (DFS) approach through the tree.

During each step in the traversal, we perform the following key calculations:

1. Determine the path that ends at the current node.

2. Compute two different subtree paths that traverse the current node.

3. Maintain an array that keeps track of the cases where paths contain either 0 or 1 prime number.

This method allows us to efficiently count the valid paths in the tree while considering the presence of prime numbers.

Read more
Всего голосов 7: ↑2 и ↓5-1
Комментарии1

LeetCode, Hard: 2818. Apply Operations to Maximize Score. Swift

Уровень сложностиСложный
Время на прочтение4 мин
Количество просмотров1.2K

Time complexityO(max(nums) * log(max(nums)) + n * log(n)). Accounting for computing prime scores, using the stack to compute next greater elements, and sorting the tuples.

Space complexityO(max(nums) + n). Considering the space required for arrays and the stack used for computation.

Read more
Всего голосов 2: ↑1 и ↓10
Комментарии1

Validation WebHook troubleshooting, how low can you go?

Уровень сложностиСредний
Время на прочтение11 мин
Количество просмотров1.5K

I'm Alex Movergan, DevOps team lead at Altenar. I focus on automation in general and on improving troubleshooting skills within my team. In this article, I'll share a captivating tale that revolves around Kubernetes, validation webhooks, kubespray, and Calico.

Join me on this DevOps journey as we explore real-world scenarios unraveling the intricacies of troubleshooting in a Kubernetes environment.

Read more
Всего голосов 4: ↑4 и ↓0+4
Комментарии2

Pairing-based identification protocols compatible with instant digital signature mode

Время на прочтение9 мин
Количество просмотров609

In our previous post, we presented a modified Schnorr protocol compatible with the Instant Digital Signature (IDS) mode and also announced the design of other protocols with this feature. In this post we describe such protocols based on the pairing function.

Read more
Всего голосов 1: ↑1 и ↓0+1
Комментарии2

React Custom Hook: useDebounce

Уровень сложностиСредний
Время на прочтение2 мин
Количество просмотров2.6K

This custom hook is particularly beneficial in scenarios where you need to handle user input, such as search bars or form fields, where you want to delay the execution of an action until the user has finished typing or interacting. It's also useful for optimizing network requests, ensuring that requests are sent only after the user has stopped typing or selecting options.

Read more
Всего голосов 3: ↑2 и ↓1+3
Комментарии0

LeetCode, Hard, last two problems: 2809. Min Time to Make Array Sum At Most x & 2813. Max Elegance of a K-Length Subseq

Уровень сложностиСложный
Время на прочтение3 мин
Количество просмотров861

2809. Min Time to Make Array Sum: Efficient Swift solution, using dynamic programming, for minimizing time to reach a sum in arrays A and B. Time: O(n²), Space: O(n).

2813. Max Elegance of K-Length Subseq: Swift code for elegantly selecting unique k-length subsequences with profit and categories. Solution uses sorting and iteration. Time: O(nlogn), Space: O(n).

Github: https://github.com/sergeyleschev/leetcode-swift

Read more
Всего голосов 1: ↑1 и ↓0+1
Комментарии2

React Custom Hook: useCopyToClipboard

Уровень сложностиСредний
Время на прочтение2 мин
Количество просмотров1.9K

Copying text to the clipboard in a React application can be a tedious task. To simplify this process, I've created a powerful custom hook called useCopyToClipboard. With just a few lines of code, this hook streamlines the copy-to-clipboard functionality, providing developers with a hassle-free solution.

Read more
Рейтинг0
Комментарии0

React Custom Hook: useCookie

Уровень сложностиСредний
Время на прочтение4 мин
Количество просмотров3.7K

One of the key advantages of this custom hook is the ability to update the cookie value. The updateCookie function, returned by useCookie, enables you to modify the value of the cookie. By invoking this function with a new value and optional options, such as expiration or path, you can instantly update the cookie.

Read more
Рейтинг0
Комментарии0

React Custom Hook: useClickOutside

Уровень сложностиСредний
Время на прочтение2 мин
Количество просмотров3.6K

The potential applications for useClickOutside are endless. It is particularly useful when implementing modal windows, dropdown menus, or any element that should be closed when a user interacts with anything outside of it. By incorporating useClickOutside, you can enhance the user experience by providing intuitive and efficient interactions.

Read more
Рейтинг0
Комментарии3

React Custom Hook: useAsync

Уровень сложностиСредний
Время на прочтение2 мин
Количество просмотров3.5K

By utilizing useAsync, you can streamline your React codebase, enhance reusability, and maintain a consistent and reliable user experience. Give it a try in your next React project and witness the power of simplified asynchronous operations.

Read more
Рейтинг0
Комментарии0

React Custom Hook: useTimeout

Уровень сложностиСредний
Время на прочтение2 мин
Количество просмотров2K

One of the significant advantages of this custom hook is that it ensures the callback function remains up to date even if it changes during component re-renders. By using a useRef to store the callback reference, the hook guarantees that the latest version of the function is always called.

Read more
Всего голосов 3: ↑1 и ↓20
Комментарии1

React Custom Hook: useStorage

Уровень сложностиСредний
Время на прочтение3 мин
Количество просмотров2.3K

One of the key advantages of this custom hook is its simplicity. You can use it to store any type of data, such as strings, numbers, or even complex objects, with just a few lines of code. Additionally, useStorage handles the serialization and deserialization of data for you, so you don't have to worry about converting values to and from JSON.

Read more
Всего голосов 2: ↑1 и ↓1+1
Комментарии0

React Custom Hook: useStateWithValidation

Уровень сложностиСредний
Время на прочтение2 мин
Количество просмотров1.6K

One of the key advantages of this custom hook is its flexibility. You can pass any validation function that suits your specific requirements. Whether it's checking the length of a string, ensuring a numeric value falls within a certain range, or performing more complex validations, useStateWithValidation has got you covered.

Read more
Всего голосов 2: ↑1 и ↓1+1
Комментарии0

React Custom Hook: useStateWithHistory

Уровень сложностиСредний
Время на прочтение3 мин
Количество просмотров2K

In this article series, we embark on a journey through the realm of custom React hooks, discovering their immense potential for elevating your development projects. Our focus today is on the "useStateWithHistory" hook, one of the many carefully crafted hooks available in the collection of React custom hooks.

Read more
Всего голосов 1: ↑0 и ↓1-1
Комментарии1

React Custom Hook: useScript

Уровень сложностиСредний
Время на прочтение2 мин
Количество просмотров2.7K

useScript can be used in various scenarios. For instance, you can load external libraries like jQuery, enabling you to harness its powerful functionalities without adding bulk to your bundle. Additionally, you can load analytics scripts, social media widgets, or any other script necessary for your application's dynamic behavior.

Read more
Всего голосов 2: ↑1 и ↓1+2
Комментарии1

React Custom Hook: useRenderCount

Уровень сложностиСредний
Время на прочтение2 мин
Количество просмотров1.5K

One of the major advantages of using useRenderCount is its simplicity. By abstracting the logic into a reusable hook, you can easily integrate it into any component without cluttering your codebase. Additionally, it provides a clear and concise way to monitor render behavior, which can be crucial for performance optimization and debugging.

Read more
Всего голосов 2: ↑1 и ↓1+1
Комментарии0

React Custom Hook: usePrevious

Уровень сложностиСредний
Время на прочтение2 мин
Количество просмотров6.3K

This custom hook can be a game-changer in various scenarios. For instance, you can utilize usePrevious to compare and visualize changes in data, track state transitions, or implement undo/redo functionality. Additionally, it can be valuable in form handling, animations, and any situation where having access to the previous value is crucial for your application's logic.

Read more
Всего голосов 2: ↑1 и ↓1+1
Комментарии0

React Custom Hook: useOnScreen

Уровень сложностиСредний
Время на прочтение2 мин
Количество просмотров3.2K

One of the key advantages of useOnScreen is its simplicity. With just a few lines of code, you can detect if an element is visible and respond accordingly. This can be immensely useful in scenarios where you want to trigger animations, lazy load images, or load additional content as the user scrolls.

Read more
Всего голосов 2: ↑1 и ↓1+1
Комментарии2

React Custom Hook: useOnlineStatus

Уровень сложностиСредний
Время на прочтение2 мин
Количество просмотров1.9K

One of the main advantages of "useOnlineStatus" is its simplicity. By importing and using this hook in your component, you can effortlessly access the online status of the user. The hook internally uses the "navigator.onLine" property to determine the initial online status and dynamically updates it whenever the user's connectivity changes.

Read more
Рейтинг0
Комментарии0

React Custom Hook: useMediaQuery

Уровень сложностиСредний
Время на прочтение2 мин
Количество просмотров3.6K

One of the key advantages of this custom hook is its simplicity and reusability. With just a few lines of code, you can effortlessly implement responsive behavior throughout your application. Whether you need to conditionally render components, apply specific styles, or trigger different functionality based on screen size, useMediaQuery has got you covered.

Read more
Всего голосов 2: ↑1 и ↓1+1
Комментарии0
1

Информация

В рейтинге
Не участвует
Дата рождения
Зарегистрирован
Активность

Специализация

Fullstack Developer, Mobile Application Developer
Lead
SWIFT
SwiftUI
TypeScript
Node.js
React
JavaScript
SQL
PostgreSQL
DevOps
React Native