Skip to content

Latest commit

History

109 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

easypython

Simple python scripts solving well known programming interview questions

  • test1 - clones an undirected graph represented with a label and list of neighboring nodes
  • test2 - solves NQueens puzzle which is the problem of placing n queens on an n×n chessboard such that no two queens attack each other
  • test3 - finds the best time to buy and sell a stock once or unlimited times or fix number of times to make the maximum profit
  • test4 - recovers a binary search tree with 2 replaced nodes
  • test5 - implements a search typehead
  • test6 - implements preorder, inorder, and postorder traversals of a binary tree with and without using recursion
  • test7 - finds the largest rectangle in a histogram
  • test8 - finds the kth minimum number in a list
  • test9 - determines if two strings are anagram or not
  • test10 - implements bubble sort, insertion sort, quick sort, merge sort, and bucket sort algorithms
  • test11 - reorders a linked list L1->L2->...->LN-1->LN into L1->LN->L2->LN-1->...
  • test12 - finds the median of an array which is created by merging two sorted arrays in O(log n+m)
  • test13 - implements a simple vending machine
  • test14 - removes duplicate entries in a list
  • test15 - checks if 2 strings are rotation of each other
  • test16 - reverses words in a given sentence without using any library method
  • test17 - finds the nth node from the end in a singly linked list in one pass
  • test18 - finds the shortest sequence between two words start and end by changing single character each time and requiring all intermediary words in a word dictionary
  • test19 - finds all combinations of a string
  • test20 - checks if a string is a palindrome
  • test21 - reverses a singly linked list
  • test22 - creates a binary tree iterator
  • test23 - searches an integer in a presorted integer array which was rotated from an unknown pivot point (array has no duplicates)
  • test24 - finds the middle node in a linked list in one pass
  • test25 - prints all leaves of a binary tree
  • test26 - counts the occurrence of each word in a list
  • test27 - implements a binary tree
  • test28 - finds the least common ancestor in a binary search tree
  • test29 - finds the maximum depth of a binary tree
  • test30 - returns level order of a binary tree
  • test31 - finds the common words in two lists
  • test32 - finds list of all unique triplets in a list of integers satisfying a+b+c=0 in non-descending order
  • test33 - reads a text file and creates another text file with the reversed file content
  • test34 - finds starting position of substrings in a string S where each substring is a combination of all substrings provided in a list L
  • test35 - intermixes two strings after crerating chunks in size n e.g. ABCDEFG and 1234567890 with 2 char chunks -> AB12CD34EF56G7890
  • test36 - reverses words in a paragraph
  • test37 - finds a, b, c, d values such that A[a]+A[b] = A[c] + A[d] where a < b and c < d and a < c and b != d and b != c
  • test38 - finds largest distance between nodes of a tree
  • test39 - finds stepping numbers between two integers e.g. A=10, B=40 output = [10, 12, 21, 23, 32, 34]
  • test40 - checks if a string has all digits
  • test41 - demonstrates trying and catching exceptions while getting a positive integer as an input and printing its square
  • test42 - finds the kth minimum number in a list (another version)
  • test43 - manipulates a number string by adding a "*" between two consecutive even numbers and "-" between two consecutive odd numbers
  • test44 - implements power function with modulo operator
  • test45 - searches for a range (a, b) in a sorted integer array A where a and b represent the first and last occurences of integer B
  • test46 - reverses a linked list partially between two values
  • test47 - calculates combination sum of a set of numbers (C) such that sum equals to target number (T)
  • test48 - finds all unique permutations of a list of numbers
  • test49 - evaluates an expression in reverse polish notation
  • test50 - finds contiguous subarray within an array, A of length N which has the largest sum
  • test51 - finds duplicate characters in a string
  • test52 - finds if parentheses are balanced in a string
  • test53 - generates all combinations of n pairs of well-formed parentheses
  • test54 - finds Fibonacci numbers for a given positive integer (finds the Fibonacci of 10M on a Mac with 32GB memory)
  • test55 - rearranges a list such that A[i] becomes A[A[i]] where A[i] has N elements such that 0<=A[i]<=N-1
  • test56 - rotates a matrix 90 degrees clockwise without using another matrix
  • test57 - finds a substring in a string
  • test58 - converts an integer N into a roman numeral where 1 < N < 4000
  • test59 - converts a JSON string into prettyJSON format
  • test60 - finds if the list A with sorted integers have 2 indices such that A[i] - A[j] = k where k is a positive integer and i != j (space optimized)
  • test61 - finds 3 numbers with a sum closest to a given integer T in a list of integers S
  • test62 - implements eval function for arithmetic operands *,/,+,-
  • test63 - finds all unique paths in a grid of MxN size between points (1,1) and (M,N)
  • test64 - sorts a list of colors 0, 1, and 2 in minimum number of swaps (O(N) complexity)
  • test65 - computes and returns the square root of integer A as floor(sqrt(A)) where 1<=A<=10^9
  • test66 - calculates the nth integer in "count and say" list
  • test67 - adds two binary strings
  • test68 - finds the length of the shortest string to be appended to turn a string into a palindrome
  • test69 - matches two regular expression strings
  • test70 - finds all possible letter combinations of for digits dialed on a letter phone
  • test71 - finds sliding window maximums of an integer array
  • test72 - finds all permutations of items in a list
  • test73 - solves gas station problem
  • test74 - finds the maximum length of list of disjoint intervals for a given list of intervals
  • test75 - finds the majority element in a list
  • test76 - prints the first non-repeated character from a string
  • test77 - finds the minimum number of cuts to create palindromes from a string
  • test78 - solves the word break problem which determines if a string consists of substrings all found in a dictionary
  • test79 - finds the size of the largest rectangle in a binary matrix
  • test80 - finds the size of the largest rectangle in a binary matrix in O(NxN) time complexity
  • test81 - finds the minimum number of steps to convert string A into string B
  • test82 - cuts a rod from the weak points of the rod in an order to minimize the rod cutting cost where cutting each rod costs the length of the rod
  • test83 - distributes minimum number of candies to N children each with a priority
  • test84 - inserts a new interval into a list of intervals which are non-overlapping and sorted based on start times
  • test85 - deletes all nodes with duplicate numbers in a sorted linked list
  • test86 - merges two sorted linked lists
  • test87 - swaps all two adjacent nodes in a linked list and returns its head
  • test88 - partitions a linked list such that all nodes with a value less than X come before all nodes with value greater than or equal to X
  • test89 - reverses a string by using recursion
  • test90 - returns elements of an NxM matrix in spiral order
  • test91 - sorts a linkled list by using insertion sort
  • test92 - finds subsets of a list of distinct integers and returns them in the non-descending order
  • test93 - creates a list with only unique items
  • test94 - approximates the Pi value by accumulating the distance among point increments on the upper right quartile of the circle
  • test95 - finds the intersection of two linked lists in O(N) time and O(1) memory
  • test96 - finds if the list A with sorted integers have 2 indices such that A[i] - A[j] = k where k is a positive integer and i != j (time optimized)
  • test97 - adds two non-negative numbers stored in two linked lists where digits are stored in reverse order and each node contains a single digit.
  • test98 - evaluates an expression in reverse polish notation
  • test99 - reverse a linked list
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
GitHub - okany/easypython: Simple python scripts solving well known programming challenge questions · GitHub
Skip to content

Latest commit

History

109 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

easypython

Simple python scripts solving well known programming interview questions

  • test1 - clones an undirected graph represented with a label and list of neighboring nodes
  • test2 - solves NQueens puzzle which is the problem of placing n queens on an n×n chessboard such that no two queens attack each other
  • test3 - finds the best time to buy and sell a stock once or unlimited times or fix number of times to make the maximum profit
  • test4 - recovers a binary search tree with 2 replaced nodes
  • test5 - implements a search typehead
  • test6 - implements preorder, inorder, and postorder traversals of a binary tree with and without using recursion
  • test7 - finds the largest rectangle in a histogram
  • test8 - finds the kth minimum number in a list
  • test9 - determines if two strings are anagram or not
  • test10 - implements bubble sort, insertion sort, quick sort, merge sort, and bucket sort algorithms
  • test11 - reorders a linked list L1->L2->...->LN-1->LN into L1->LN->L2->LN-1->...
  • test12 - finds the median of an array which is created by merging two sorted arrays in O(log n+m)
  • test13 - implements a simple vending machine
  • test14 - removes duplicate entries in a list
  • test15 - checks if 2 strings are rotation of each other
  • test16 - reverses words in a given sentence without using any library method
  • test17 - finds the nth node from the end in a singly linked list in one pass
  • test18 - finds the shortest sequence between two words start and end by changing single character each time and requiring all intermediary words in a word dictionary
  • test19 - finds all combinations of a string
  • test20 - checks if a string is a palindrome
  • test21 - reverses a singly linked list
  • test22 - creates a binary tree iterator
  • test23 - searches an integer in a presorted integer array which was rotated from an unknown pivot point (array has no duplicates)
  • test24 - finds the middle node in a linked list in one pass
  • test25 - prints all leaves of a binary tree
  • test26 - counts the occurrence of each word in a list
  • test27 - implements a binary tree
  • test28 - finds the least common ancestor in a binary search tree
  • test29 - finds the maximum depth of a binary tree
  • test30 - returns level order of a binary tree
  • test31 - finds the common words in two lists
  • test32 - finds list of all unique triplets in a list of integers satisfying a+b+c=0 in non-descending order
  • test33 - reads a text file and creates another text file with the reversed file content
  • test34 - finds starting position of substrings in a string S where each substring is a combination of all substrings provided in a list L
  • test35 - intermixes two strings after crerating chunks in size n e.g. ABCDEFG and 1234567890 with 2 char chunks -> AB12CD34EF56G7890
  • test36 - reverses words in a paragraph
  • test37 - finds a, b, c, d values such that A[a]+A[b] = A[c] + A[d] where a < b and c < d and a < c and b != d and b != c
  • test38 - finds largest distance between nodes of a tree
  • test39 - finds stepping numbers between two integers e.g. A=10, B=40 output = [10, 12, 21, 23, 32, 34]
  • test40 - checks if a string has all digits
  • test41 - demonstrates trying and catching exceptions while getting a positive integer as an input and printing its square
  • test42 - finds the kth minimum number in a list (another version)
  • test43 - manipulates a number string by adding a "*" between two consecutive even numbers and "-" between two consecutive odd numbers
  • test44 - implements power function with modulo operator
  • test45 - searches for a range (a, b) in a sorted integer array A where a and b represent the first and last occurences of integer B
  • test46 - reverses a linked list partially between two values
  • test47 - calculates combination sum of a set of numbers (C) such that sum equals to target number (T)
  • test48 - finds all unique permutations of a list of numbers
  • test49 - evaluates an expression in reverse polish notation
  • test50 - finds contiguous subarray within an array, A of length N which has the largest sum
  • test51 - finds duplicate characters in a string
  • test52 - finds if parentheses are balanced in a string
  • test53 - generates all combinations of n pairs of well-formed parentheses
  • test54 - finds Fibonacci numbers for a given positive integer (finds the Fibonacci of 10M on a Mac with 32GB memory)
  • test55 - rearranges a list such that A[i] becomes A[A[i]] where A[i] has N elements such that 0<=A[i]<=N-1
  • test56 - rotates a matrix 90 degrees clockwise without using another matrix
  • test57 - finds a substring in a string
  • test58 - converts an integer N into a roman numeral where 1 < N < 4000
  • test59 - converts a JSON string into prettyJSON format
  • test60 - finds if the list A with sorted integers have 2 indices such that A[i] - A[j] = k where k is a positive integer and i != j (space optimized)
  • test61 - finds 3 numbers with a sum closest to a given integer T in a list of integers S
  • test62 - implements eval function for arithmetic operands *,/,+,-
  • test63 - finds all unique paths in a grid of MxN size between points (1,1) and (M,N)
  • test64 - sorts a list of colors 0, 1, and 2 in minimum number of swaps (O(N) complexity)
  • test65 - computes and returns the square root of integer A as floor(sqrt(A)) where 1<=A<=10^9
  • test66 - calculates the nth integer in "count and say" list
  • test67 - adds two binary strings
  • test68 - finds the length of the shortest string to be appended to turn a string into a palindrome
  • test69 - matches two regular expression strings
  • test70 - finds all possible letter combinations of for digits dialed on a letter phone
  • test71 - finds sliding window maximums of an integer array
  • test72 - finds all permutations of items in a list
  • test73 - solves gas station problem
  • test74 - finds the maximum length of list of disjoint intervals for a given list of intervals
  • test75 - finds the majority element in a list
  • test76 - prints the first non-repeated character from a string
  • test77 - finds the minimum number of cuts to create palindromes from a string
  • test78 - solves the word break problem which determines if a string consists of substrings all found in a dictionary
  • test79 - finds the size of the largest rectangle in a binary matrix
  • test80 - finds the size of the largest rectangle in a binary matrix in O(NxN) time complexity
  • test81 - finds the minimum number of steps to convert string A into string B
  • test82 - cuts a rod from the weak points of the rod in an order to minimize the rod cutting cost where cutting each rod costs the length of the rod
  • test83 - distributes minimum number of candies to N children each with a priority
  • test84 - inserts a new interval into a list of intervals which are non-overlapping and sorted based on start times
  • test85 - deletes all nodes with duplicate numbers in a sorted linked list
  • test86 - merges two sorted linked lists
  • test87 - swaps all two adjacent nodes in a linked list and returns its head
  • test88 - partitions a linked list such that all nodes with a value less than X come before all nodes with value greater than or equal to X
  • test89 - reverses a string by using recursion
  • test90 - returns elements of an NxM matrix in spiral order
  • test91 - sorts a linkled list by using insertion sort
  • test92 - finds subsets of a list of distinct integers and returns them in the non-descending order
  • test93 - creates a list with only unique items
  • test94 - approximates the Pi value by accumulating the distance among point increments on the upper right quartile of the circle
  • test95 - finds the intersection of two linked lists in O(N) time and O(1) memory
  • test96 - finds if the list A with sorted integers have 2 indices such that A[i] - A[j] = k where k is a positive integer and i != j (time optimized)
  • test97 - adds two non-negative numbers stored in two linked lists where digits are stored in reverse order and each node contains a single digit.
  • test98 - evaluates an expression in reverse polish notation
  • test99 - reverse a linked list
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - okany/easypython: Simple python scripts solving well known programming challenge questions · GitHub
Skip to content

Latest commit

History

109 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

easypython

Simple python scripts solving well known programming interview questions

  • test1 - clones an undirected graph represented with a label and list of neighboring nodes
  • test2 - solves NQueens puzzle which is the problem of placing n queens on an n×n chessboard such that no two queens attack each other
  • test3 - finds the best time to buy and sell a stock once or unlimited times or fix number of times to make the maximum profit
  • test4 - recovers a binary search tree with 2 replaced nodes
  • test5 - implements a search typehead
  • test6 - implements preorder, inorder, and postorder traversals of a binary tree with and without using recursion
  • test7 - finds the largest rectangle in a histogram
  • test8 - finds the kth minimum number in a list
  • test9 - determines if two strings are anagram or not
  • test10 - implements bubble sort, insertion sort, quick sort, merge sort, and bucket sort algorithms
  • test11 - reorders a linked list L1->L2->...->LN-1->LN into L1->LN->L2->LN-1->...
  • test12 - finds the median of an array which is created by merging two sorted arrays in O(log n+m)
  • test13 - implements a simple vending machine
  • test14 - removes duplicate entries in a list
  • test15 - checks if 2 strings are rotation of each other
  • test16 - reverses words in a given sentence without using any library method
  • test17 - finds the nth node from the end in a singly linked list in one pass
  • test18 - finds the shortest sequence between two words start and end by changing single character each time and requiring all intermediary words in a word dictionary
  • test19 - finds all combinations of a string
  • test20 - checks if a string is a palindrome
  • test21 - reverses a singly linked list
  • test22 - creates a binary tree iterator
  • test23 - searches an integer in a presorted integer array which was rotated from an unknown pivot point (array has no duplicates)
  • test24 - finds the middle node in a linked list in one pass
  • test25 - prints all leaves of a binary tree
  • test26 - counts the occurrence of each word in a list
  • test27 - implements a binary tree
  • test28 - finds the least common ancestor in a binary search tree
  • test29 - finds the maximum depth of a binary tree
  • test30 - returns level order of a binary tree
  • test31 - finds the common words in two lists
  • test32 - finds list of all unique triplets in a list of integers satisfying a+b+c=0 in non-descending order
  • test33 - reads a text file and creates another text file with the reversed file content
  • test34 - finds starting position of substrings in a string S where each substring is a combination of all substrings provided in a list L
  • test35 - intermixes two strings after crerating chunks in size n e.g. ABCDEFG and 1234567890 with 2 char chunks -> AB12CD34EF56G7890
  • test36 - reverses words in a paragraph
  • test37 - finds a, b, c, d values such that A[a]+A[b] = A[c] + A[d] where a < b and c < d and a < c and b != d and b != c
  • test38 - finds largest distance between nodes of a tree
  • test39 - finds stepping numbers between two integers e.g. A=10, B=40 output = [10, 12, 21, 23, 32, 34]
  • test40 - checks if a string has all digits
  • test41 - demonstrates trying and catching exceptions while getting a positive integer as an input and printing its square
  • test42 - finds the kth minimum number in a list (another version)
  • test43 - manipulates a number string by adding a "*" between two consecutive even numbers and "-" between two consecutive odd numbers
  • test44 - implements power function with modulo operator
  • test45 - searches for a range (a, b) in a sorted integer array A where a and b represent the first and last occurences of integer B
  • test46 - reverses a linked list partially between two values
  • test47 - calculates combination sum of a set of numbers (C) such that sum equals to target number (T)
  • test48 - finds all unique permutations of a list of numbers
  • test49 - evaluates an expression in reverse polish notation
  • test50 - finds contiguous subarray within an array, A of length N which has the largest sum
  • test51 - finds duplicate characters in a string
  • test52 - finds if parentheses are balanced in a string
  • test53 - generates all combinations of n pairs of well-formed parentheses
  • test54 - finds Fibonacci numbers for a given positive integer (finds the Fibonacci of 10M on a Mac with 32GB memory)
  • test55 - rearranges a list such that A[i] becomes A[A[i]] where A[i] has N elements such that 0<=A[i]<=N-1
  • test56 - rotates a matrix 90 degrees clockwise without using another matrix
  • test57 - finds a substring in a string
  • test58 - converts an integer N into a roman numeral where 1 < N < 4000
  • test59 - converts a JSON string into prettyJSON format
  • test60 - finds if the list A with sorted integers have 2 indices such that A[i] - A[j] = k where k is a positive integer and i != j (space optimized)
  • test61 - finds 3 numbers with a sum closest to a given integer T in a list of integers S
  • test62 - implements eval function for arithmetic operands *,/,+,-
  • test63 - finds all unique paths in a grid of MxN size between points (1,1) and (M,N)
  • test64 - sorts a list of colors 0, 1, and 2 in minimum number of swaps (O(N) complexity)
  • test65 - computes and returns the square root of integer A as floor(sqrt(A)) where 1<=A<=10^9
  • test66 - calculates the nth integer in "count and say" list
  • test67 - adds two binary strings
  • test68 - finds the length of the shortest string to be appended to turn a string into a palindrome
  • test69 - matches two regular expression strings
  • test70 - finds all possible letter combinations of for digits dialed on a letter phone
  • test71 - finds sliding window maximums of an integer array
  • test72 - finds all permutations of items in a list
  • test73 - solves gas station problem
  • test74 - finds the maximum length of list of disjoint intervals for a given list of intervals
  • test75 - finds the majority element in a list
  • test76 - prints the first non-repeated character from a string
  • test77 - finds the minimum number of cuts to create palindromes from a string
  • test78 - solves the word break problem which determines if a string consists of substrings all found in a dictionary
  • test79 - finds the size of the largest rectangle in a binary matrix
  • test80 - finds the size of the largest rectangle in a binary matrix in O(NxN) time complexity
  • test81 - finds the minimum number of steps to convert string A into string B
  • test82 - cuts a rod from the weak points of the rod in an order to minimize the rod cutting cost where cutting each rod costs the length of the rod
  • test83 - distributes minimum number of candies to N children each with a priority
  • test84 - inserts a new interval into a list of intervals which are non-overlapping and sorted based on start times
  • test85 - deletes all nodes with duplicate numbers in a sorted linked list
  • test86 - merges two sorted linked lists
  • test87 - swaps all two adjacent nodes in a linked list and returns its head
  • test88 - partitions a linked list such that all nodes with a value less than X come before all nodes with value greater than or equal to X
  • test89 - reverses a string by using recursion
  • test90 - returns elements of an NxM matrix in spiral order
  • test91 - sorts a linkled list by using insertion sort
  • test92 - finds subsets of a list of distinct integers and returns them in the non-descending order
  • test93 - creates a list with only unique items
  • test94 - approximates the Pi value by accumulating the distance among point increments on the upper right quartile of the circle
  • test95 - finds the intersection of two linked lists in O(N) time and O(1) memory
  • test96 - finds if the list A with sorted integers have 2 indices such that A[i] - A[j] = k where k is a positive integer and i != j (time optimized)
  • test97 - adds two non-negative numbers stored in two linked lists where digits are stored in reverse order and each node contains a single digit.
  • test98 - evaluates an expression in reverse polish notation
  • test99 - reverse a linked list
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - okany/easypython: Simple python scripts solving well known programming challenge questions · GitHub
Skip to content

Latest commit

History

109 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

easypython

Simple python scripts solving well known programming interview questions

  • test1 - clones an undirected graph represented with a label and list of neighboring nodes
  • test2 - solves NQueens puzzle which is the problem of placing n queens on an n×n chessboard such that no two queens attack each other
  • test3 - finds the best time to buy and sell a stock once or unlimited times or fix number of times to make the maximum profit
  • test4 - recovers a binary search tree with 2 replaced nodes
  • test5 - implements a search typehead
  • test6 - implements preorder, inorder, and postorder traversals of a binary tree with and without using recursion
  • test7 - finds the largest rectangle in a histogram
  • test8 - finds the kth minimum number in a list
  • test9 - determines if two strings are anagram or not
  • test10 - implements bubble sort, insertion sort, quick sort, merge sort, and bucket sort algorithms
  • test11 - reorders a linked list L1->L2->...->LN-1->LN into L1->LN->L2->LN-1->...
  • test12 - finds the median of an array which is created by merging two sorted arrays in O(log n+m)
  • test13 - implements a simple vending machine
  • test14 - removes duplicate entries in a list
  • test15 - checks if 2 strings are rotation of each other
  • test16 - reverses words in a given sentence without using any library method
  • test17 - finds the nth node from the end in a singly linked list in one pass
  • test18 - finds the shortest sequence between two words start and end by changing single character each time and requiring all intermediary words in a word dictionary
  • test19 - finds all combinations of a string
  • test20 - checks if a string is a palindrome
  • test21 - reverses a singly linked list
  • test22 - creates a binary tree iterator
  • test23 - searches an integer in a presorted integer array which was rotated from an unknown pivot point (array has no duplicates)
  • test24 - finds the middle node in a linked list in one pass
  • test25 - prints all leaves of a binary tree
  • test26 - counts the occurrence of each word in a list
  • test27 - implements a binary tree
  • test28 - finds the least common ancestor in a binary search tree
  • test29 - finds the maximum depth of a binary tree
  • test30 - returns level order of a binary tree
  • test31 - finds the common words in two lists
  • test32 - finds list of all unique triplets in a list of integers satisfying a+b+c=0 in non-descending order
  • test33 - reads a text file and creates another text file with the reversed file content
  • test34 - finds starting position of substrings in a string S where each substring is a combination of all substrings provided in a list L
  • test35 - intermixes two strings after crerating chunks in size n e.g. ABCDEFG and 1234567890 with 2 char chunks -> AB12CD34EF56G7890
  • test36 - reverses words in a paragraph
  • test37 - finds a, b, c, d values such that A[a]+A[b] = A[c] + A[d] where a < b and c < d and a < c and b != d and b != c
  • test38 - finds largest distance between nodes of a tree
  • test39 - finds stepping numbers between two integers e.g. A=10, B=40 output = [10, 12, 21, 23, 32, 34]
  • test40 - checks if a string has all digits
  • test41 - demonstrates trying and catching exceptions while getting a positive integer as an input and printing its square
  • test42 - finds the kth minimum number in a list (another version)
  • test43 - manipulates a number string by adding a "*" between two consecutive even numbers and "-" between two consecutive odd numbers
  • test44 - implements power function with modulo operator
  • test45 - searches for a range (a, b) in a sorted integer array A where a and b represent the first and last occurences of integer B
  • test46 - reverses a linked list partially between two values
  • test47 - calculates combination sum of a set of numbers (C) such that sum equals to target number (T)
  • test48 - finds all unique permutations of a list of numbers
  • test49 - evaluates an expression in reverse polish notation
  • test50 - finds contiguous subarray within an array, A of length N which has the largest sum
  • test51 - finds duplicate characters in a string
  • test52 - finds if parentheses are balanced in a string
  • test53 - generates all combinations of n pairs of well-formed parentheses
  • test54 - finds Fibonacci numbers for a given positive integer (finds the Fibonacci of 10M on a Mac with 32GB memory)
  • test55 - rearranges a list such that A[i] becomes A[A[i]] where A[i] has N elements such that 0<=A[i]<=N-1
  • test56 - rotates a matrix 90 degrees clockwise without using another matrix
  • test57 - finds a substring in a string
  • test58 - converts an integer N into a roman numeral where 1 < N < 4000
  • test59 - converts a JSON string into prettyJSON format
  • test60 - finds if the list A with sorted integers have 2 indices such that A[i] - A[j] = k where k is a positive integer and i != j (space optimized)
  • test61 - finds 3 numbers with a sum closest to a given integer T in a list of integers S
  • test62 - implements eval function for arithmetic operands *,/,+,-
  • test63 - finds all unique paths in a grid of MxN size between points (1,1) and (M,N)
  • test64 - sorts a list of colors 0, 1, and 2 in minimum number of swaps (O(N) complexity)
  • test65 - computes and returns the square root of integer A as floor(sqrt(A)) where 1<=A<=10^9
  • test66 - calculates the nth integer in "count and say" list
  • test67 - adds two binary strings
  • test68 - finds the length of the shortest string to be appended to turn a string into a palindrome
  • test69 - matches two regular expression strings
  • test70 - finds all possible letter combinations of for digits dialed on a letter phone
  • test71 - finds sliding window maximums of an integer array
  • test72 - finds all permutations of items in a list
  • test73 - solves gas station problem
  • test74 - finds the maximum length of list of disjoint intervals for a given list of intervals
  • test75 - finds the majority element in a list
  • test76 - prints the first non-repeated character from a string
  • test77 - finds the minimum number of cuts to create palindromes from a string
  • test78 - solves the word break problem which determines if a string consists of substrings all found in a dictionary
  • test79 - finds the size of the largest rectangle in a binary matrix
  • test80 - finds the size of the largest rectangle in a binary matrix in O(NxN) time complexity
  • test81 - finds the minimum number of steps to convert string A into string B
  • test82 - cuts a rod from the weak points of the rod in an order to minimize the rod cutting cost where cutting each rod costs the length of the rod
  • test83 - distributes minimum number of candies to N children each with a priority
  • test84 - inserts a new interval into a list of intervals which are non-overlapping and sorted based on start times
  • test85 - deletes all nodes with duplicate numbers in a sorted linked list
  • test86 - merges two sorted linked lists
  • test87 - swaps all two adjacent nodes in a linked list and returns its head
  • test88 - partitions a linked list such that all nodes with a value less than X come before all nodes with value greater than or equal to X
  • test89 - reverses a string by using recursion
  • test90 - returns elements of an NxM matrix in spiral order
  • test91 - sorts a linkled list by using insertion sort
  • test92 - finds subsets of a list of distinct integers and returns them in the non-descending order
  • test93 - creates a list with only unique items
  • test94 - approximates the Pi value by accumulating the distance among point increments on the upper right quartile of the circle
  • test95 - finds the intersection of two linked lists in O(N) time and O(1) memory
  • test96 - finds if the list A with sorted integers have 2 indices such that A[i] - A[j] = k where k is a positive integer and i != j (time optimized)
  • test97 - adds two non-negative numbers stored in two linked lists where digits are stored in reverse order and each node contains a single digit.
  • test98 - evaluates an expression in reverse polish notation
  • test99 - reverse a linked list
, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' GitHub - okany/easypython: Simple python scripts solving well known programming challenge questions · GitHub
Skip to content

Latest commit

History

109 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

easypython

Simple python scripts solving well known programming interview questions

  • test1 - clones an undirected graph represented with a label and list of neighboring nodes
  • test2 - solves NQueens puzzle which is the problem of placing n queens on an n×n chessboard such that no two queens attack each other
  • test3 - finds the best time to buy and sell a stock once or unlimited times or fix number of times to make the maximum profit
  • test4 - recovers a binary search tree with 2 replaced nodes
  • test5 - implements a search typehead
  • test6 - implements preorder, inorder, and postorder traversals of a binary tree with and without using recursion
  • test7 - finds the largest rectangle in a histogram
  • test8 - finds the kth minimum number in a list
  • test9 - determines if two strings are anagram or not
  • test10 - implements bubble sort, insertion sort, quick sort, merge sort, and bucket sort algorithms
  • test11 - reorders a linked list L1->L2->...->LN-1->LN into L1->LN->L2->LN-1->...
  • test12 - finds the median of an array which is created by merging two sorted arrays in O(log n+m)
  • test13 - implements a simple vending machine
  • test14 - removes duplicate entries in a list
  • test15 - checks if 2 strings are rotation of each other
  • test16 - reverses words in a given sentence without using any library method
  • test17 - finds the nth node from the end in a singly linked list in one pass
  • test18 - finds the shortest sequence between two words start and end by changing single character each time and requiring all intermediary words in a word dictionary
  • test19 - finds all combinations of a string
  • test20 - checks if a string is a palindrome
  • test21 - reverses a singly linked list
  • test22 - creates a binary tree iterator
  • test23 - searches an integer in a presorted integer array which was rotated from an unknown pivot point (array has no duplicates)
  • test24 - finds the middle node in a linked list in one pass
  • test25 - prints all leaves of a binary tree
  • test26 - counts the occurrence of each word in a list
  • test27 - implements a binary tree
  • test28 - finds the least common ancestor in a binary search tree
  • test29 - finds the maximum depth of a binary tree
  • test30 - returns level order of a binary tree
  • test31 - finds the common words in two lists
  • test32 - finds list of all unique triplets in a list of integers satisfying a+b+c=0 in non-descending order
  • test33 - reads a text file and creates another text file with the reversed file content
  • test34 - finds starting position of substrings in a string S where each substring is a combination of all substrings provided in a list L
  • test35 - intermixes two strings after crerating chunks in size n e.g. ABCDEFG and 1234567890 with 2 char chunks -> AB12CD34EF56G7890
  • test36 - reverses words in a paragraph
  • test37 - finds a, b, c, d values such that A[a]+A[b] = A[c] + A[d] where a < b and c < d and a < c and b != d and b != c
  • test38 - finds largest distance between nodes of a tree
  • test39 - finds stepping numbers between two integers e.g. A=10, B=40 output = [10, 12, 21, 23, 32, 34]
  • test40 - checks if a string has all digits
  • test41 - demonstrates trying and catching exceptions while getting a positive integer as an input and printing its square
  • test42 - finds the kth minimum number in a list (another version)
  • test43 - manipulates a number string by adding a "*" between two consecutive even numbers and "-" between two consecutive odd numbers
  • test44 - implements power function with modulo operator
  • test45 - searches for a range (a, b) in a sorted integer array A where a and b represent the first and last occurences of integer B
  • test46 - reverses a linked list partially between two values
  • test47 - calculates combination sum of a set of numbers (C) such that sum equals to target number (T)
  • test48 - finds all unique permutations of a list of numbers
  • test49 - evaluates an expression in reverse polish notation
  • test50 - finds contiguous subarray within an array, A of length N which has the largest sum
  • test51 - finds duplicate characters in a string
  • test52 - finds if parentheses are balanced in a string
  • test53 - generates all combinations of n pairs of well-formed parentheses
  • test54 - finds Fibonacci numbers for a given positive integer (finds the Fibonacci of 10M on a Mac with 32GB memory)
  • test55 - rearranges a list such that A[i] becomes A[A[i]] where A[i] has N elements such that 0<=A[i]<=N-1
  • test56 - rotates a matrix 90 degrees clockwise without using another matrix
  • test57 - finds a substring in a string
  • test58 - converts an integer N into a roman numeral where 1 < N < 4000
  • test59 - converts a JSON string into prettyJSON format
  • test60 - finds if the list A with sorted integers have 2 indices such that A[i] - A[j] = k where k is a positive integer and i != j (space optimized)
  • test61 - finds 3 numbers with a sum closest to a given integer T in a list of integers S
  • test62 - implements eval function for arithmetic operands *,/,+,-
  • test63 - finds all unique paths in a grid of MxN size between points (1,1) and (M,N)
  • test64 - sorts a list of colors 0, 1, and 2 in minimum number of swaps (O(N) complexity)
  • test65 - computes and returns the square root of integer A as floor(sqrt(A)) where 1<=A<=10^9
  • test66 - calculates the nth integer in "count and say" list
  • test67 - adds two binary strings
  • test68 - finds the length of the shortest string to be appended to turn a string into a palindrome
  • test69 - matches two regular expression strings
  • test70 - finds all possible letter combinations of for digits dialed on a letter phone
  • test71 - finds sliding window maximums of an integer array
  • test72 - finds all permutations of items in a list
  • test73 - solves gas station problem
  • test74 - finds the maximum length of list of disjoint intervals for a given list of intervals
  • test75 - finds the majority element in a list
  • test76 - prints the first non-repeated character from a string
  • test77 - finds the minimum number of cuts to create palindromes from a string
  • test78 - solves the word break problem which determines if a string consists of substrings all found in a dictionary
  • test79 - finds the size of the largest rectangle in a binary matrix
  • test80 - finds the size of the largest rectangle in a binary matrix in O(NxN) time complexity
  • test81 - finds the minimum number of steps to convert string A into string B
  • test82 - cuts a rod from the weak points of the rod in an order to minimize the rod cutting cost where cutting each rod costs the length of the rod
  • test83 - distributes minimum number of candies to N children each with a priority
  • test84 - inserts a new interval into a list of intervals which are non-overlapping and sorted based on start times
  • test85 - deletes all nodes with duplicate numbers in a sorted linked list
  • test86 - merges two sorted linked lists
  • test87 - swaps all two adjacent nodes in a linked list and returns its head
  • test88 - partitions a linked list such that all nodes with a value less than X come before all nodes with value greater than or equal to X
  • test89 - reverses a string by using recursion
  • test90 - returns elements of an NxM matrix in spiral order
  • test91 - sorts a linkled list by using insertion sort
  • test92 - finds subsets of a list of distinct integers and returns them in the non-descending order
  • test93 - creates a list with only unique items
  • test94 - approximates the Pi value by accumulating the distance among point increments on the upper right quartile of the circle
  • test95 - finds the intersection of two linked lists in O(N) time and O(1) memory
  • test96 - finds if the list A with sorted integers have 2 indices such that A[i] - A[j] = k where k is a positive integer and i != j (time optimized)
  • test97 - adds two non-negative numbers stored in two linked lists where digits are stored in reverse order and each node contains a single digit.
  • test98 - evaluates an expression in reverse polish notation
  • test99 - reverse a linked list
, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - okany/easypython: Simple python scripts solving well known programming challenge questions · GitHub
Skip to content

Latest commit

History

109 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

easypython

Simple python scripts solving well known programming interview questions

  • test1 - clones an undirected graph represented with a label and list of neighboring nodes
  • test2 - solves NQueens puzzle which is the problem of placing n queens on an n×n chessboard such that no two queens attack each other
  • test3 - finds the best time to buy and sell a stock once or unlimited times or fix number of times to make the maximum profit
  • test4 - recovers a binary search tree with 2 replaced nodes
  • test5 - implements a search typehead
  • test6 - implements preorder, inorder, and postorder traversals of a binary tree with and without using recursion
  • test7 - finds the largest rectangle in a histogram
  • test8 - finds the kth minimum number in a list
  • test9 - determines if two strings are anagram or not
  • test10 - implements bubble sort, insertion sort, quick sort, merge sort, and bucket sort algorithms
  • test11 - reorders a linked list L1->L2->...->LN-1->LN into L1->LN->L2->LN-1->...
  • test12 - finds the median of an array which is created by merging two sorted arrays in O(log n+m)
  • test13 - implements a simple vending machine
  • test14 - removes duplicate entries in a list
  • test15 - checks if 2 strings are rotation of each other
  • test16 - reverses words in a given sentence without using any library method
  • test17 - finds the nth node from the end in a singly linked list in one pass
  • test18 - finds the shortest sequence between two words start and end by changing single character each time and requiring all intermediary words in a word dictionary
  • test19 - finds all combinations of a string
  • test20 - checks if a string is a palindrome
  • test21 - reverses a singly linked list
  • test22 - creates a binary tree iterator
  • test23 - searches an integer in a presorted integer array which was rotated from an unknown pivot point (array has no duplicates)
  • test24 - finds the middle node in a linked list in one pass
  • test25 - prints all leaves of a binary tree
  • test26 - counts the occurrence of each word in a list
  • test27 - implements a binary tree
  • test28 - finds the least common ancestor in a binary search tree
  • test29 - finds the maximum depth of a binary tree
  • test30 - returns level order of a binary tree
  • test31 - finds the common words in two lists
  • test32 - finds list of all unique triplets in a list of integers satisfying a+b+c=0 in non-descending order
  • test33 - reads a text file and creates another text file with the reversed file content
  • test34 - finds starting position of substrings in a string S where each substring is a combination of all substrings provided in a list L
  • test35 - intermixes two strings after crerating chunks in size n e.g. ABCDEFG and 1234567890 with 2 char chunks -> AB12CD34EF56G7890
  • test36 - reverses words in a paragraph
  • test37 - finds a, b, c, d values such that A[a]+A[b] = A[c] + A[d] where a < b and c < d and a < c and b != d and b != c
  • test38 - finds largest distance between nodes of a tree
  • test39 - finds stepping numbers between two integers e.g. A=10, B=40 output = [10, 12, 21, 23, 32, 34]
  • test40 - checks if a string has all digits
  • test41 - demonstrates trying and catching exceptions while getting a positive integer as an input and printing its square
  • test42 - finds the kth minimum number in a list (another version)
  • test43 - manipulates a number string by adding a "*" between two consecutive even numbers and "-" between two consecutive odd numbers
  • test44 - implements power function with modulo operator
  • test45 - searches for a range (a, b) in a sorted integer array A where a and b represent the first and last occurences of integer B
  • test46 - reverses a linked list partially between two values
  • test47 - calculates combination sum of a set of numbers (C) such that sum equals to target number (T)
  • test48 - finds all unique permutations of a list of numbers
  • test49 - evaluates an expression in reverse polish notation
  • test50 - finds contiguous subarray within an array, A of length N which has the largest sum
  • test51 - finds duplicate characters in a string
  • test52 - finds if parentheses are balanced in a string
  • test53 - generates all combinations of n pairs of well-formed parentheses
  • test54 - finds Fibonacci numbers for a given positive integer (finds the Fibonacci of 10M on a Mac with 32GB memory)
  • test55 - rearranges a list such that A[i] becomes A[A[i]] where A[i] has N elements such that 0<=A[i]<=N-1
  • test56 - rotates a matrix 90 degrees clockwise without using another matrix
  • test57 - finds a substring in a string
  • test58 - converts an integer N into a roman numeral where 1 < N < 4000
  • test59 - converts a JSON string into prettyJSON format
  • test60 - finds if the list A with sorted integers have 2 indices such that A[i] - A[j] = k where k is a positive integer and i != j (space optimized)
  • test61 - finds 3 numbers with a sum closest to a given integer T in a list of integers S
  • test62 - implements eval function for arithmetic operands *,/,+,-
  • test63 - finds all unique paths in a grid of MxN size between points (1,1) and (M,N)
  • test64 - sorts a list of colors 0, 1, and 2 in minimum number of swaps (O(N) complexity)
  • test65 - computes and returns the square root of integer A as floor(sqrt(A)) where 1<=A<=10^9
  • test66 - calculates the nth integer in "count and say" list
  • test67 - adds two binary strings
  • test68 - finds the length of the shortest string to be appended to turn a string into a palindrome
  • test69 - matches two regular expression strings
  • test70 - finds all possible letter combinations of for digits dialed on a letter phone
  • test71 - finds sliding window maximums of an integer array
  • test72 - finds all permutations of items in a list
  • test73 - solves gas station problem
  • test74 - finds the maximum length of list of disjoint intervals for a given list of intervals
  • test75 - finds the majority element in a list
  • test76 - prints the first non-repeated character from a string
  • test77 - finds the minimum number of cuts to create palindromes from a string
  • test78 - solves the word break problem which determines if a string consists of substrings all found in a dictionary
  • test79 - finds the size of the largest rectangle in a binary matrix
  • test80 - finds the size of the largest rectangle in a binary matrix in O(NxN) time complexity
  • test81 - finds the minimum number of steps to convert string A into string B
  • test82 - cuts a rod from the weak points of the rod in an order to minimize the rod cutting cost where cutting each rod costs the length of the rod
  • test83 - distributes minimum number of candies to N children each with a priority
  • test84 - inserts a new interval into a list of intervals which are non-overlapping and sorted based on start times
  • test85 - deletes all nodes with duplicate numbers in a sorted linked list
  • test86 - merges two sorted linked lists
  • test87 - swaps all two adjacent nodes in a linked list and returns its head
  • test88 - partitions a linked list such that all nodes with a value less than X come before all nodes with value greater than or equal to X
  • test89 - reverses a string by using recursion
  • test90 - returns elements of an NxM matrix in spiral order
  • test91 - sorts a linkled list by using insertion sort
  • test92 - finds subsets of a list of distinct integers and returns them in the non-descending order
  • test93 - creates a list with only unique items
  • test94 - approximates the Pi value by accumulating the distance among point increments on the upper right quartile of the circle
  • test95 - finds the intersection of two linked lists in O(N) time and O(1) memory
  • test96 - finds if the list A with sorted integers have 2 indices such that A[i] - A[j] = k where k is a positive integer and i != j (time optimized)
  • test97 - adds two non-negative numbers stored in two linked lists where digits are stored in reverse order and each node contains a single digit.
  • test98 - evaluates an expression in reverse polish notation
  • test99 - reverse a linked list
, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - okany/easypython: Simple python scripts solving well known programming challenge questions · GitHub
Skip to content

Latest commit

History

109 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

easypython

Simple python scripts solving well known programming interview questions

  • test1 - clones an undirected graph represented with a label and list of neighboring nodes
  • test2 - solves NQueens puzzle which is the problem of placing n queens on an n×n chessboard such that no two queens attack each other
  • test3 - finds the best time to buy and sell a stock once or unlimited times or fix number of times to make the maximum profit
  • test4 - recovers a binary search tree with 2 replaced nodes
  • test5 - implements a search typehead
  • test6 - implements preorder, inorder, and postorder traversals of a binary tree with and without using recursion
  • test7 - finds the largest rectangle in a histogram
  • test8 - finds the kth minimum number in a list
  • test9 - determines if two strings are anagram or not
  • test10 - implements bubble sort, insertion sort, quick sort, merge sort, and bucket sort algorithms
  • test11 - reorders a linked list L1->L2->...->LN-1->LN into L1->LN->L2->LN-1->...
  • test12 - finds the median of an array which is created by merging two sorted arrays in O(log n+m)
  • test13 - implements a simple vending machine
  • test14 - removes duplicate entries in a list
  • test15 - checks if 2 strings are rotation of each other
  • test16 - reverses words in a given sentence without using any library method
  • test17 - finds the nth node from the end in a singly linked list in one pass
  • test18 - finds the shortest sequence between two words start and end by changing single character each time and requiring all intermediary words in a word dictionary
  • test19 - finds all combinations of a string
  • test20 - checks if a string is a palindrome
  • test21 - reverses a singly linked list
  • test22 - creates a binary tree iterator
  • test23 - searches an integer in a presorted integer array which was rotated from an unknown pivot point (array has no duplicates)
  • test24 - finds the middle node in a linked list in one pass
  • test25 - prints all leaves of a binary tree
  • test26 - counts the occurrence of each word in a list
  • test27 - implements a binary tree
  • test28 - finds the least common ancestor in a binary search tree
  • test29 - finds the maximum depth of a binary tree
  • test30 - returns level order of a binary tree
  • test31 - finds the common words in two lists
  • test32 - finds list of all unique triplets in a list of integers satisfying a+b+c=0 in non-descending order
  • test33 - reads a text file and creates another text file with the reversed file content
  • test34 - finds starting position of substrings in a string S where each substring is a combination of all substrings provided in a list L
  • test35 - intermixes two strings after crerating chunks in size n e.g. ABCDEFG and 1234567890 with 2 char chunks -> AB12CD34EF56G7890
  • test36 - reverses words in a paragraph
  • test37 - finds a, b, c, d values such that A[a]+A[b] = A[c] + A[d] where a < b and c < d and a < c and b != d and b != c
  • test38 - finds largest distance between nodes of a tree
  • test39 - finds stepping numbers between two integers e.g. A=10, B=40 output = [10, 12, 21, 23, 32, 34]
  • test40 - checks if a string has all digits
  • test41 - demonstrates trying and catching exceptions while getting a positive integer as an input and printing its square
  • test42 - finds the kth minimum number in a list (another version)
  • test43 - manipulates a number string by adding a "*" between two consecutive even numbers and "-" between two consecutive odd numbers
  • test44 - implements power function with modulo operator
  • test45 - searches for a range (a, b) in a sorted integer array A where a and b represent the first and last occurences of integer B
  • test46 - reverses a linked list partially between two values
  • test47 - calculates combination sum of a set of numbers (C) such that sum equals to target number (T)
  • test48 - finds all unique permutations of a list of numbers
  • test49 - evaluates an expression in reverse polish notation
  • test50 - finds contiguous subarray within an array, A of length N which has the largest sum
  • test51 - finds duplicate characters in a string
  • test52 - finds if parentheses are balanced in a string
  • test53 - generates all combinations of n pairs of well-formed parentheses
  • test54 - finds Fibonacci numbers for a given positive integer (finds the Fibonacci of 10M on a Mac with 32GB memory)
  • test55 - rearranges a list such that A[i] becomes A[A[i]] where A[i] has N elements such that 0<=A[i]<=N-1
  • test56 - rotates a matrix 90 degrees clockwise without using another matrix
  • test57 - finds a substring in a string
  • test58 - converts an integer N into a roman numeral where 1 < N < 4000
  • test59 - converts a JSON string into prettyJSON format
  • test60 - finds if the list A with sorted integers have 2 indices such that A[i] - A[j] = k where k is a positive integer and i != j (space optimized)
  • test61 - finds 3 numbers with a sum closest to a given integer T in a list of integers S
  • test62 - implements eval function for arithmetic operands *,/,+,-
  • test63 - finds all unique paths in a grid of MxN size between points (1,1) and (M,N)
  • test64 - sorts a list of colors 0, 1, and 2 in minimum number of swaps (O(N) complexity)
  • test65 - computes and returns the square root of integer A as floor(sqrt(A)) where 1<=A<=10^9
  • test66 - calculates the nth integer in "count and say" list
  • test67 - adds two binary strings
  • test68 - finds the length of the shortest string to be appended to turn a string into a palindrome
  • test69 - matches two regular expression strings
  • test70 - finds all possible letter combinations of for digits dialed on a letter phone
  • test71 - finds sliding window maximums of an integer array
  • test72 - finds all permutations of items in a list
  • test73 - solves gas station problem
  • test74 - finds the maximum length of list of disjoint intervals for a given list of intervals
  • test75 - finds the majority element in a list
  • test76 - prints the first non-repeated character from a string
  • test77 - finds the minimum number of cuts to create palindromes from a string
  • test78 - solves the word break problem which determines if a string consists of substrings all found in a dictionary
  • test79 - finds the size of the largest rectangle in a binary matrix
  • test80 - finds the size of the largest rectangle in a binary matrix in O(NxN) time complexity
  • test81 - finds the minimum number of steps to convert string A into string B
  • test82 - cuts a rod from the weak points of the rod in an order to minimize the rod cutting cost where cutting each rod costs the length of the rod
  • test83 - distributes minimum number of candies to N children each with a priority
  • test84 - inserts a new interval into a list of intervals which are non-overlapping and sorted based on start times
  • test85 - deletes all nodes with duplicate numbers in a sorted linked list
  • test86 - merges two sorted linked lists
  • test87 - swaps all two adjacent nodes in a linked list and returns its head
  • test88 - partitions a linked list such that all nodes with a value less than X come before all nodes with value greater than or equal to X
  • test89 - reverses a string by using recursion
  • test90 - returns elements of an NxM matrix in spiral order
  • test91 - sorts a linkled list by using insertion sort
  • test92 - finds subsets of a list of distinct integers and returns them in the non-descending order
  • test93 - creates a list with only unique items
  • test94 - approximates the Pi value by accumulating the distance among point increments on the upper right quartile of the circle
  • test95 - finds the intersection of two linked lists in O(N) time and O(1) memory
  • test96 - finds if the list A with sorted integers have 2 indices such that A[i] - A[j] = k where k is a positive integer and i != j (time optimized)
  • test97 - adds two non-negative numbers stored in two linked lists where digits are stored in reverse order and each node contains a single digit.
  • test98 - evaluates an expression in reverse polish notation
  • test99 - reverse a linked list
, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })(); GitHub - okany/easypython: Simple python scripts solving well known programming challenge questions · GitHub
Skip to content

Latest commit

History

109 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

easypython

Simple python scripts solving well known programming interview questions

  • test1 - clones an undirected graph represented with a label and list of neighboring nodes
  • test2 - solves NQueens puzzle which is the problem of placing n queens on an n×n chessboard such that no two queens attack each other
  • test3 - finds the best time to buy and sell a stock once or unlimited times or fix number of times to make the maximum profit
  • test4 - recovers a binary search tree with 2 replaced nodes
  • test5 - implements a search typehead
  • test6 - implements preorder, inorder, and postorder traversals of a binary tree with and without using recursion
  • test7 - finds the largest rectangle in a histogram
  • test8 - finds the kth minimum number in a list
  • test9 - determines if two strings are anagram or not
  • test10 - implements bubble sort, insertion sort, quick sort, merge sort, and bucket sort algorithms
  • test11 - reorders a linked list L1->L2->...->LN-1->LN into L1->LN->L2->LN-1->...
  • test12 - finds the median of an array which is created by merging two sorted arrays in O(log n+m)
  • test13 - implements a simple vending machine
  • test14 - removes duplicate entries in a list
  • test15 - checks if 2 strings are rotation of each other
  • test16 - reverses words in a given sentence without using any library method
  • test17 - finds the nth node from the end in a singly linked list in one pass
  • test18 - finds the shortest sequence between two words start and end by changing single character each time and requiring all intermediary words in a word dictionary
  • test19 - finds all combinations of a string
  • test20 - checks if a string is a palindrome
  • test21 - reverses a singly linked list
  • test22 - creates a binary tree iterator
  • test23 - searches an integer in a presorted integer array which was rotated from an unknown pivot point (array has no duplicates)
  • test24 - finds the middle node in a linked list in one pass
  • test25 - prints all leaves of a binary tree
  • test26 - counts the occurrence of each word in a list
  • test27 - implements a binary tree
  • test28 - finds the least common ancestor in a binary search tree
  • test29 - finds the maximum depth of a binary tree
  • test30 - returns level order of a binary tree
  • test31 - finds the common words in two lists
  • test32 - finds list of all unique triplets in a list of integers satisfying a+b+c=0 in non-descending order
  • test33 - reads a text file and creates another text file with the reversed file content
  • test34 - finds starting position of substrings in a string S where each substring is a combination of all substrings provided in a list L
  • test35 - intermixes two strings after crerating chunks in size n e.g. ABCDEFG and 1234567890 with 2 char chunks -> AB12CD34EF56G7890
  • test36 - reverses words in a paragraph
  • test37 - finds a, b, c, d values such that A[a]+A[b] = A[c] + A[d] where a < b and c < d and a < c and b != d and b != c
  • test38 - finds largest distance between nodes of a tree
  • test39 - finds stepping numbers between two integers e.g. A=10, B=40 output = [10, 12, 21, 23, 32, 34]
  • test40 - checks if a string has all digits
  • test41 - demonstrates trying and catching exceptions while getting a positive integer as an input and printing its square
  • test42 - finds the kth minimum number in a list (another version)
  • test43 - manipulates a number string by adding a "*" between two consecutive even numbers and "-" between two consecutive odd numbers
  • test44 - implements power function with modulo operator
  • test45 - searches for a range (a, b) in a sorted integer array A where a and b represent the first and last occurences of integer B
  • test46 - reverses a linked list partially between two values
  • test47 - calculates combination sum of a set of numbers (C) such that sum equals to target number (T)
  • test48 - finds all unique permutations of a list of numbers
  • test49 - evaluates an expression in reverse polish notation
  • test50 - finds contiguous subarray within an array, A of length N which has the largest sum
  • test51 - finds duplicate characters in a string
  • test52 - finds if parentheses are balanced in a string
  • test53 - generates all combinations of n pairs of well-formed parentheses
  • test54 - finds Fibonacci numbers for a given positive integer (finds the Fibonacci of 10M on a Mac with 32GB memory)
  • test55 - rearranges a list such that A[i] becomes A[A[i]] where A[i] has N elements such that 0<=A[i]<=N-1
  • test56 - rotates a matrix 90 degrees clockwise without using another matrix
  • test57 - finds a substring in a string
  • test58 - converts an integer N into a roman numeral where 1 < N < 4000
  • test59 - converts a JSON string into prettyJSON format
  • test60 - finds if the list A with sorted integers have 2 indices such that A[i] - A[j] = k where k is a positive integer and i != j (space optimized)
  • test61 - finds 3 numbers with a sum closest to a given integer T in a list of integers S
  • test62 - implements eval function for arithmetic operands *,/,+,-
  • test63 - finds all unique paths in a grid of MxN size between points (1,1) and (M,N)
  • test64 - sorts a list of colors 0, 1, and 2 in minimum number of swaps (O(N) complexity)
  • test65 - computes and returns the square root of integer A as floor(sqrt(A)) where 1<=A<=10^9
  • test66 - calculates the nth integer in "count and say" list
  • test67 - adds two binary strings
  • test68 - finds the length of the shortest string to be appended to turn a string into a palindrome
  • test69 - matches two regular expression strings
  • test70 - finds all possible letter combinations of for digits dialed on a letter phone
  • test71 - finds sliding window maximums of an integer array
  • test72 - finds all permutations of items in a list
  • test73 - solves gas station problem
  • test74 - finds the maximum length of list of disjoint intervals for a given list of intervals
  • test75 - finds the majority element in a list
  • test76 - prints the first non-repeated character from a string
  • test77 - finds the minimum number of cuts to create palindromes from a string
  • test78 - solves the word break problem which determines if a string consists of substrings all found in a dictionary
  • test79 - finds the size of the largest rectangle in a binary matrix
  • test80 - finds the size of the largest rectangle in a binary matrix in O(NxN) time complexity
  • test81 - finds the minimum number of steps to convert string A into string B
  • test82 - cuts a rod from the weak points of the rod in an order to minimize the rod cutting cost where cutting each rod costs the length of the rod
  • test83 - distributes minimum number of candies to N children each with a priority
  • test84 - inserts a new interval into a list of intervals which are non-overlapping and sorted based on start times
  • test85 - deletes all nodes with duplicate numbers in a sorted linked list
  • test86 - merges two sorted linked lists
  • test87 - swaps all two adjacent nodes in a linked list and returns its head
  • test88 - partitions a linked list such that all nodes with a value less than X come before all nodes with value greater than or equal to X
  • test89 - reverses a string by using recursion
  • test90 - returns elements of an NxM matrix in spiral order
  • test91 - sorts a linkled list by using insertion sort
  • test92 - finds subsets of a list of distinct integers and returns them in the non-descending order
  • test93 - creates a list with only unique items
  • test94 - approximates the Pi value by accumulating the distance among point increments on the upper right quartile of the circle
  • test95 - finds the intersection of two linked lists in O(N) time and O(1) memory
  • test96 - finds if the list A with sorted integers have 2 indices such that A[i] - A[j] = k where k is a positive integer and i != j (time optimized)
  • test97 - adds two non-negative numbers stored in two linked lists where digits are stored in reverse order and each node contains a single digit.
  • test98 - evaluates an expression in reverse polish notation
  • test99 - reverse a linked list