Conversation
appgurueu
left a comment
There was a problem hiding this comment.
Definitely an improvement overall. I have some minor comments.
|
Ohh nice, tks for review. i'll fix this today xD |
|
@appgurueu, sorry for the delay, fixed the issues ✅ |
badr222222
left a comment
There was a problem hiding this comment.
I think the data base was mest up at first but think if there was a few of us we can do it
badr222222
left a comment
There was a problem hiding this comment.
23 changes: 12 additions & 11 deletions 23
Sorts/SimplifiedWiggleSort.js
Viewed
@@ -8,29 +8,30 @@
import { quickSelectSearch } from '../Search/QuickSelectSearch.js'
export const simplifiedWiggleSort = function (arr) {
const arrSize = arr.length
CarlosZoft marked this conversation as resolved.
// find Median using QuickSelect
let median = quickSelectSearch(arr, Math.floor(arr.length / 2.0))
median = median[Math.floor(arr.length / 2.0)]
let median = quickSelectSearch(arr, Math.floor(arrSize / 2.0))
median = median[Math.floor(arrSize / 2.0)]
const sorted = new Array(arr.length)
const sorted = new Array(arrSize)
let smallerThanMedianIndx = 0
let greaterThanMedianIndx = arr.length - 1 - (arr.length % 2)
let greaterThanMedianIndx = arrSize - 1 - (arrSize % 2)
for (let i = 0; i < arr.length; i++) {
if (arr[i] > median) {
sorted[greaterThanMedianIndx] = arr[i]
arr.forEach(element => {
if (element > median) {
sorted[greaterThanMedianIndx] = element
greaterThanMedianIndx -= 2
} else {
if (smallerThanMedianIndx < arr.length) {
sorted[smallerThanMedianIndx] = arr[i]
if (smallerThanMedianIndx < arrSize) {
sorted[smallerThanMedianIndx] = element
smallerThanMedianIndx += 2
} else {
sorted[greaterThanMedianIndx] = arr[i]
sorted[greaterThanMedianIndx] = element
greaterThanMedianIndx -= 2
}
}
}
})
return sorted
}
2 changes: 1 addition & 1 deletion 2
String/CheckRearrangePalindrome.js
Viewed
@@ -12,7 +12,7 @@ export const palindromeRearranging = (str) => {
return 'Not a string'
}
// Check if is a empty string
if (str.length === 0) {
if (!str) {
return 'Empty string'
}
Use this
Describe your change:
Some minor algorithm fixes
Checklist:
Example:
UserProfile.jsis allowed butuserprofile.js,Userprofile.js,user-Profile.js,userProfile.jsare notFixes: #{$ISSUE_NO}.