Product of Array Except Self

Problem Given an integer array nums, return an array answer such that answer[i] is equal to the product of all the elements of nums except nums[i]. The product of any prefix or suffix of nums is guaranteed to fit in a 32-bit integer. You must write an algorithm that runs in O(n) time and without using the division operation. Example 1: Input: nums = [1,2,3,4] Output: [24,12,8,6] Example 2: Input: nums = [-1,1,0,-3,3] Output: [0,0,9,0,0] Constraints:...

June 11, 2023 · 3 min · 630 words · Altynbek Usenbekov

Top K Frequent Elements | Quickselect | O(N)

This problem can be solved using either the Heap (Priority Queue) approach, which has a time complexity of O(N log k), or the Sorting approach, which has a time complexity of O(N log N). We can return the answer in any order, so a better approach is to use Quickselect. It has an average time complexity of O(N) and a worst-case complexity of O(N2), although the probability of encountering the worst-case scenario is negligible....

June 8, 2023 · 4 min · 737 words · Altynbek Usenbekov

How to Change the Voice of SpeechSynthesis with JavaScript?

SpeechSynthesis is used to read text out loud on web browsers using JavaScript, provided that the browser supports Text-to-Speech. It is a component of the Web Speech API, which includes SpeechSynthesis (Text-to-Speech) and SpeechRecognition (Asynchronous Speech Recognition). How to change the voice Usually, platforms provide a list of voice options, and we can select one of those voices for the speech. The available voices may depend on the operating system and browser....

April 12, 2023 · 2 min · 286 words · Altynbek Usenbekov

Which Browsers Support Web Speech API's Text-to-Speech?

Here is a list of desktop and mobile browsers that support and do not support the Web Speech API's Text-to-Speech ( SpeechSynthesis) Component, and the versions when support began. Desktop browsers that support Chrome 33 (Released 2014-02-20) Edge 14 (Released 2016-08-02) Firefox 49 (Released 2016-09-20) Opera 21 (Released 2014-05-06) Safari 7 (Released 2013-10-22) Mobile browsers that support Chrome Android 33 (Released 2014-02-26) Firefox for Android 62 (Released 2018-09-05) Safari on iOS 7 (Released 2013-09-18) Samsung Internet 3....

April 12, 2023 · 1 min · 205 words · Altynbek Usenbekov

Exploring the Text-to-Speech with the Web Speech API and CodePen Example

Text-to-speech (TTS) is a really helpful technology that lets you hear written text out loud. It's great for folks who may have difficulty reading or seeing what's on a screen, and it's also used to give spoken feedback or assistance. In this article, we'll take a look at how to use TTS with JavaScript on the browser. Check if your browser supports all Text-to-Speech features Here is a Web Tool that lets you enter your own text and have it read aloud....

April 1, 2023 · 7 min · 1468 words · Altynbek Usenbekov