Skip to content

Instantly share code, notes, and snippets.

View OlegKorn's full-sized avatar
💭
SEEK FOR A JUNIOR QA JOB

O OlegKorn

💭
SEEK FOR A JUNIOR QA JOB
View GitHub Profile
/*
Write a function to find the longest common prefix
string amongst an array of strings.
If there is no common prefix, return an empty string "".
Example 1:
Input: strs = ["flower","flow","flight"]
Output: "fl"
/*
nums1.length == m
nums2.length == n
0 <= m <= 1000
0 <= n <= 1000
1 <= m + n <= 2000
-10**6 <= nums1[i], nums2[i] <= 10**6
*/
var findMedianSortedArrays = function(nums1, nums2) {
/*
author Oleg Kornilov
kornilovoy@gmail.com
Runtime: 2025 ms, faster than 11.72% of JavaScript online submissions for Longest Palindromic Substring.
Memory Usage: 52 MB, less than 12.11% of JavaScript online submissions for Longest Palindromic Substring.
*/
var longestPalindrome = function(s) {
@OlegKorn
OlegKorn / palindrom.js
Created October 12, 2022 07:07
leetcode - Palindrom.js
/*
author Oleg Kornilov
kornilovoy@gmail.com
github.com/OlegKorn
https://leetcode.com/problems/palindrome-number/solution/
*/
var isPalindrome = function(x) {
x = x.toString()
@OlegKorn
OlegKorn / twoSum.js
Created October 11, 2022 04:53
leetcode twoSum
// https://leetcode.com/problems/two-sum/
/*
author Oleg Kornilov
kornilovoy@gmail.com
Given an array of integers nums and an integer target, return indices of
the two numbers such that they add up to target.
You may assume that each input would have exactly one solution, and you
@OlegKorn
OlegKorn / bubbleSort.js
Created October 10, 2022 06:17
bubble sort JS
function bubbleSort() {
a = [33, 2, 3345, 34456456, 3, 3434, 41, 314, 34, 34445]
for (var i = 0; i < a.length; i++) {
var swapped = false
for (var j = 0; j < a.length - 1; j++) {
if (a[j] > a[j+1]) {
@OlegKorn
OlegKorn / jsFindValueByKeyInDict.js
Last active October 7, 2022 04:37
JS: finding a value by a key in dictionary
function isThereEquivalent(equivalentsArr, value) {
try {
var equivalent = Object.entries(equivalentsArr).find(([key]) => key === value.toString())[1]
return equivalent
}
catch (e) {
if (e instanceof TypeError) {
return false
}
@OlegKorn
OlegKorn / intToRoman.js
Last active October 7, 2022 04:29
leetcode - intToRoman.js
/*
author Oleg Kornilov
kornilovoy@gmail.com, https://github.com/OlegKorn
*/
var intToRoman = function(num) {
var equivalents = {
1: "I",
4: "IV",
@OlegKorn
OlegKorn / gist:9453e7b6afd70f68038cea2108a3fbab
Last active September 23, 2022 02:08
cyfor: Reports-Отгрузка на экспорт - число значений "№ декларации"
numDeclClass = "first b-list__table-col_name_name_gtd"
for (i=0; i<classes.length; i++) {
declNum = classes[i].textContent.trim()
console.log(declNum)
}
console.log("num of № декларации is: ", classes.length)
@OlegKorn
OlegKorn / Python re findall websites
Created August 31, 2021 02:34
Python re findall websites
a = '''<a href="dfsdfdsfd" target="_blank" class="_1rehek">
сайт-сайт.рф</a>
</a>ваываыва4333.РФ
<div>www.dekorm.com</div>
https://wewefds.net
http://dsdfsdfs.org
www.fsdsdfsd.РФ
сайт.тест
сайт.домен
'''