[Solved] Given two strings S and T, return if they are equal when both are typed into empty text editors. # means a backspace character

The first mistake is pushing all the characters on the stack outside of the if statement. Also you should check if stack is empty before removing items from it. Otherwise EmptyStackException is thrown. // stack1.push(S.charAt(i)); <– remove this line if (S.charAt(i)!=’#’) { stack1.push(S.charAt(i)); }else if (!stack1.isEmpty()) { // <– add this check stack1.pop(); } The … Read more

[Solved] convert a string JSON into an Array [duplicate]

Use JSON.parse() and replace the starting and ending ” with backticks JSON.parse(`[ { “userId”: 1, “id”: 1, “title”: “delectus aut autem”, “completed”: false }, { “userId”: 1, “id”: 5, “title”: “laboriosam mollitia et enim quasi adipisci quia provident illum”, “completed”: false } ]`) solved convert a string JSON into an Array [duplicate]

[Solved] I don’t know what to do next [closed]

I’ll help you with some parts, but most of this code should be a learning experience for you. import datetime # prompt here for the date # put it into a datetime.datetime object named “day” # this is the part of the code you need to type day_array = [“Monday”,”Tuesday”,”Wednesday”,”Thursday”,”Friday”,”Saturday”,”Sunday”] day_of_week = day_array[day.weekday()] The datetime … Read more

[Solved] Creating a JavaScript global array with static elements?

The problem isn’t that removeFunction doesn’t have access to bigArray. The problem is in your onclick attribute, and the id you’re putting on the link: $(‘#div’).append(“<a href=”#” id=’bigArray[i]’ onclick=’removeFunction(bigArray[i])’>Element bigArray[i]</a><br />”); In the onclick, you’re referring to i, but A) I’m guessing i isn’t a global, and B) Even if it is, it will not … Read more

[Solved] transforming elements in array from numbers to string

Map over the array and assign each key value pair to a new object after converting it to a string. const array = [{abcd:1, cdef:7},{abcd:2, cdef:8}, {abcd:3, cdef:9}]; array.map(el => { const stringObj = {} Object.keys(el).forEach(key => { stringObj[key] = el[key].toString(); }) return stringObj; }) 1 solved transforming elements in array from numbers to string

[Solved] PHP Strip specific keys in array

Assuming that you want to so something(remove Arrival) on each of the values, you can use this: <?php $results = array ( ‘date’ => ’22. jan.’, ‘flightNumber’ => ‘EZY6747’, ‘airline’ => ‘easyJet’, ‘from’ => ‘Belfast International’, ‘plannedArrival’ => ’18:35′, ‘realArrival’ => ‘Estimated Arrival 18:32’ ); $result2 = array_map(function($s) { return str_replace(‘Arrival ‘, ”, $s); }, … Read more

[Solved] How to search duplicate value in array

You can do it with simple for loop : $arr = array([“id” => 7, “a” => “”], [“id” => 6, “a” => “AAA”], [“id” => 4, “a” => “AAA”]); $ans = []; foreach($arr as $elem) $ans[$elem[“a”]][] = $elem[“id”]; This will output associative array with the “a” value as keys – if you only want to … Read more

[Solved] Heap Sort array

PriorityQueue<Integer> pQueue = new PriorityQueue<Integer>(); This line creates a priority queue of Integers. A priority queue stores a “sorted” list of items (in your case Integers). When you add an int to pQueue ,it is places the value in the correct position. E.g if I add numbers 1, 10 and 5 in this order to … Read more