What do you want to save?
Add Code snippet
New code examples
-
Python 2021-11-21 12:33:28
how to sort a list in python
# sort() will change the original list into a sorted list vowels = ['e', 'a', 'u', 'o', 'i'] vowels.sort() # Output: # ['a', 'e', 'i', 'o', 'u'] # sorted() will sort the list and return it while keeping the original sortedVowels = sorted(vowels) # Output... Add solution -
Javascript 2021-11-21 04:50:12
implement a merge sort algorithm JS
// Merge Sort Implentation (Recursive) function mergeSort (unsortedArray) { if (unsortedArray.length <= 1) { return unsortedArray; } const middle = Math.floor(unsortedArray.length / 2); const left = unsortedArray.slice(0, middle); co... Add solution -
Python 2021-11-20 22:26:12
python slice a dict
#python convert a dict to list or a list to dict or a slice a dict or sort a dict by key or value without import #convert dict to list or list to dict or slice a dict #1. convert dict to list temp = [] # not required as [] is mentioned below s = {'b': 3, ... Add solution -
TypeScript 2021-11-20 05:38:11
longest increasing subsequence when elements hae duplicates
#include <iostream> #include <algorithm> using namespace std; // define maximum possible length of X and Y #define N 20 // lookup[i][j] stores the length of LCS of subarray X[0..i-1], Y[0..j-1] int lookup[N][N]; // Functio... Add solution -
Python 2021-11-20 01:42:12
.sort python
my_list = [9, 3, 1, 5, 88, 22, 99] # sort in decreasing order my_list = sorted(my_list, reverse=True) print(my_list) # sort in increasing order my_list = sorted(my_list, reverse=False) print(my_list) # another way to sort using built-in methods my_li... Add solution -
Python 2021-11-19 06:42:15
Square of numbers in non-decreasing order
""" Given an integer array sorted in non-decreasing order, return an array of the squares of each number sorted in non-decreasing order. """ def sortedSquares(nums): n = len(nums) start, end = 0, n - 1 result = ... Add solution