instruction
stringlengths
71
71.9k
I have a jQuery script and I should explain it line by line. I already do that and I want to make sure that is correct. If someone has any remarks, I will be very appreciative. //Here we use the jQuery selector ($) to select the servers_id which is located into //the delivers_id and we attaches a function to run wh...
I use the src.sencha.io service to resize images on the fly according to device width, saving lots of bandwidth on mobiles etc. Sometimes the service fails randomly with a 503 error, so a fallback is needed. I've written this JS to fallback to "non-sencha" urls, and emit an error event, if the first image requested thr...
The results variable is coming from an API that have a arrays in arrays, etc. I have made a foreach with for loops inside, which looks like this: foreach (var s in results) { var dataRowsCollection = s.ResultRows; for (int g = 0; g <= dataRowsCollection.Count; g++) { for (int i = 0; i <= dataRowsCo...
I'm attempting to apply a long set of conditions and operations onto a pandas dataframe (see the dataframe below with VTI, upper, lower, etc). I attempted to use apply, but I was having a lot of trouble doing so. My current solution (which works perfectly) relies on a for loop iterating through the dataframe. But my se...
I wrote some compare-functions that I pass to other methods in javascript: function equal(a, b) { if (a instanceof Date) return a.getTime() == b.getTime(); return a == b; } function lessThan(a, b) { if (a instanceof Date) return a.getTime() < b.getTime(); return a < b; } function greaterThan(a, b) { ...
This code currently works, but I'm new to Objective-C from a Python/PHP background. How can I improve it/make it more Objective-Cesque? Header File/Interface #import <Foundation/Foundation.h> @interface Monster : NSObject @property NSString* name; @property NSNumber* health; @property NSNumber* strength; @property N...
I am relatively new to JavaScript/jQuery, and cobbled together a script. Essentially, the script sets individual timers on specific DOM elements, and then recursively applies timed functions to them. The functions actually apply a "flip" effect to a div, showing a front and back, and then do different things on each si...
I have a small little function in a VB6 codebase: Public Function GetEquivalentCode(Optional ByVal code As String) As String If IsMissing(code) Or code = vbNullString Then code = m_GlobalCode Dim result As String If StringStartsWith("ABC", code) Then result = "ABC2013" Else result = c...
Based on the true condition, I am making some operations. But I want to simplify the below HTML code in a better way. @{ bool savingHtml = (Request.QueryString["savehtml"] == "1"); string activeTab = Request.QueryString["from"]; } @if (savingHtml) { if (activeTab.ToLower() == "index") { <div c...
I recently posted a question about modeling a system that contains elements that can perform actions (here). The model runs in cycles and parts perform their action every cycle. The model should have some kind of visual representation displaying changes in model state. In my test code the model updated on timer events ...
I'm creating a game that implements a finite automaton and I don't know if I'm doing it right. Any advice? Game class import java.awt.Canvas; import java.awt.event.KeyListener; import java.awt.Dimension; import java.awt.Graphics; import java.awt.event.KeyEvent; import java.awt.image.BufferStrategy; import java.awt.imag...
I am populating a drop down list from my SQL database. List should be able to be displayed with active only, inactive only or both at the same time. OfficeRepository.cs: public static List<OfficeRollups> ListOfficeRollups(bool active, bool inactive) { List<DataRow> listDataRow = null; string wh...
I'm adding additional functionality to an existing MVC .net application, and to help prevent or at least reduce repeated reads to the dB I'm dumping a few custom entities in session. I'm limiting what can be stored in session to say a max of 5 objects for now. Given below is the code and it seems generic enough and wo...
I implemented a fixed-size matrix class which supports basic matrix operations (cannot use C++11). What do you think, and how could it be improved? #ifndef FIXED_SIZE_MATRIX_H__ #define FIXED_SIZE_MATRIX_H__ #include <iostream> #include <cstdlib> template <typename Ty, int N, int M = N> struct FixedSizeMatrix { typ...
How could I make this code more effective? I'm just experimenting and learning the different ways of how Python runs. list=[] original=mkPoint3D(x,y) z1=mkPoint3D(x-d,y) z2=mkPoint3D(x+d,y) z3=mkPoint3D(x,y-d) z4=mkPoint3D(x,y+d) list.append(original) list.append(z1) list.append(z2) list.append(z3) list.append(z4) if...
Is this orthogonal? #ifndef TOKENIZER_H #define TOKENIZER_H #include <iostream> #include <string> #include <sstream> #include <vector> class StringTokenizer { private: std::vector<std::string> tokens; unsigned int index; public: StringTokenizer(std::string const & str, const char delim) { ...
We have a geocoding samples github repository. The snippet below came through in an email and I am not very familiar with PHP. I'd like to add this as the PHP example in the samples repository but would like someone to review it first. The idea is that some other php dev can use this as a starting point and it will be ...
I'm writing an algorithm to take in a sample list of sequences of events, calculate 1-step transitional probabilities from the sequences, forward or in reverse, then calculate the joint probability of n events occurring from those conditional probabilities. Eg. if the sample list of sequences is: ['TTAGCAGTCAGT', 'TCA...
For this problem, I came up with this ugly solution of appending the characters to the output and in case there is adjacent duplicate deleting from the output. Considering StringBuilder.deleteCharAt(i) is O(N), performance is O(N) + O(N) = O(N). Please critique this, if this is a right way. public static String removeD...
Here is the question: find the largest palindrome from a string. Ex: ABCBAHELLOHOWRACECARAREYOUILOVEUEVOLIIAMAIDOINGGOOD Result: ILOVEUEVOLI I am not sure of the efficiency of the algorithm. static void Main(string[] args) { var str = "ABCBAHELLOHOWRACECARAREYOUILOVEUEVOLIIAMAIDOINGGOOD"; var longestPalindrom...
I'm comparing two distinct instances and if they are not the same I save to the dB, so I've given snippet of code below of the way I am comparing these instances, I realize I could use reflection and generalize but short of using reflections is there any other way I could optimize the code or make it neater? publ...
Regex parser which follows the following rule . (dot) means a any single character match * (star) means 0 or more character match ? (question) means previous char is an option i.e colou?r matches color and colour. A large feedback has been taken from here. I'm looking for code review, optimizations, best practices....
I'm trying to tidy the following fragment of code: if (this.Details.Recipients.Count > 0) this.Recipient = this.Details.Recipients[0]; else { this.Recipient = new Contact(); this.Details.Recipients.Add(this.Recipient); } if (this.Details.CCs.Co...
I had three multi-select boxes from this page. I want to customize each box so I simply repeat the code three times with different options: Check the fiddle $(".choose").multiselect({ header: "Choose only One item!", multiple: false, noneSelectedText: "Select an Option", selectedList: 1 }); $(".pick").mul...
I appreciate any feedback on where I might alter or improve my code for this project. This is an old attempt at implementing a Hierarchical State Machine in F#. I'm from a C#/OO background mostly. module FSharp.HSM open Option open System.Collections.Generic exception NoTransition exception NotInitialized exceptio...
I am trying to solve this SPOJ question. #include<iostream> #include<cstdio> #include<math.h> #define l long long using namespace std; l chk(l a) { for(int i=2;i<=sqrt(a);++i) { if(a%i==0) { return a/i; } } return 0; } main() { // freopen("in.txt","r",stdin); ...
I have been working on a linked list for some while now and started out with this. Is my code clean? Or is there some way to make it better and more readable? The reason for this question is for me to be a better programmer. I would love to get one step further for making more clean code. my class: using namespace st...
I'd like to get some input on whether or not to DRY up this code. And if so how to implement it correctly. How do I know when it's worth refactoring? public class Win32OperatingSystem { public Win32OperatingSystem() { } /// <summary> /// Number, in megabytes, of physical memory currently unused and availa...
I'm writing a simple table-oriented storage for objects. The schema of a table is stored in the columns-array and the data in the rows-array. // example: table "employees" var columns = ["id", "name"] var rows = [[1, "Alice"], [2, "Bob"]]; I wrote a function to convert a row-array into an object: function convertRowTo...
I've been suggested to put the following snippet of code up for review, hence I will do so, review of everything is appreciated, also posting as much relevant code as possible: abstract public class Primitive { protected List<VertexData> vertexData; public List<VertexData> getVertexData() { return vert...
I want to factor out the AsyncTask to a Manager. I thought to make it a singleton, but then I cannot use generics as the object to serialize to JSON and send (e.g. PostManager<T>). How can this be refactored? public class RestPostActivity extends BaseActivity implements OnClickListener { ... public static String P...
I have a program that processes Microsoft Office documents (and other kinds, but primarily Office). I am replacing one purchased product that performs this processing with a new one. This new product consists of a library which is linked in to my code and a Windows service, which performs the actual work. For the most ...
I just want to checking if this kind of routing is good or bad? I implement the routing of my web appl to something like this. All page will be pointing to the index.php in index.php I have this code $url = array_values(array_filter( explode( '/', strtolower($_SERVER["REQUEST_URI"]) ) ) ); switch( $url[0] ) { case...
This question specifically relates to the use of the class constants ABOVE and BELOW in the sample code below. I have a few different classes that look like this: class MyClass(object): ABOVE = 1 BELOW = 0 def __init__(self): self.my_numbers = [1,2,3,4,5] def find_thing_in_direction(self, dire...
I am building a PHP framework and would like to get some feedback on a few different sections of the project so far. I consider myself still a neophyte in PHP so I would like to ask if I'm going about completing these different tasks in an efficient and or correct way. I am currently working on a session management cl...
I am writing a Sudoku solver in C, but am having problems with how long it takes to run. It can solve easier puzzles but once I put in one a little more difficult it runs and runs and never stops. int solver (int x, int y) { int a; int b; int i; int j; printf("Depth: %d\n", counter); for (a=1; a<10; a++) ...
I want a thread safe list with a max item count, will the following implementation correctly provide this? public class ConcurrentThrottledList<T> { private readonly List<T> items = new List<T>(); private readonly int maxItems; private object _lock = new object(); public ConcurrentThrottledList(int ma...
I need to take data from a MySQL database and message it into a format expected by the front end of an application - I can not change the front end as other services provide it data in this same format. The database is structured as follows: id type value label optgroup 1 car ix5 Ford Ta...
After reading @JavaDeveloper's recent question, I was inspired1 to try my hand at writing code to accomplish the same task. The "rules" for this code (i.e., its intent) is to match a subset of regular expressions, defined as follows: . (dot) means a any single character match * (star) means 0 or more character match ...
This is my first attempt to create an STL-compliant container. I'd like to know whether it meets STL concepts & requirements, so feel free to critique. list.h #include <cstdint> #include <limits> #include <memory> #include <iterator> #include <type_traits> #include <initializer_list> #include <algo...
Today, I tried to create a really simple sparse_array container adapter. I did not provide all the STL-like functions, only the elementary ones as a proof of concept. I also trimmed the class from its copy constructor and all the unecessary things for this review actually. Here is the code: #include <cstddef> #include ...
In an example game engine server, the game world could be represented by a World object. The game might have multiple game worlds and a player who is in a world only needs to receive position data of units in that world. class World { public List<Unit> Units { get; set; } } However a piece of code also needs to be...
Task: Draw a grid with a given number of rows and columns. Each cell can be any color. The same grid should also be updated at a predetermined time interval. The grid should cover the entire visible portion of the page in the browser. Add a context menu with which you can change the parameters of the lattice...
I am trying to upload an image (screenshot from desktop) to an SQL database as fast as possible. I would like to optimize my current procedure in terms of speed: bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, System.Drawing...
Please give me some feedback to my malloc implementation. I implemented this design to understand the basic concept. #include <stdio.h> #include <stdbool.h> #include <string.h> #define HEAP_MEM_SIZE 150 #define MEMORY_AVAILABLE 1 #define MEMORY_USED 0 struct chunk_header { struct chunk_header *next; // next poin...
I put together this implementation after playing around with various partitioning- and pivot-strategies, and it runs fine. I wrote this off a version which seemed a bit different from the majority of implementations, so I'm curious on what you guys think. It works and handles duplicates. def quicksort(a, min=0, max=a.l...
I have been trying to create a class that would list prime numbers forever. I know it has already been done but I think I learned some valuable principles during my trials. This project helped me understand (to a better extent) return values, arguments for methods, simple math arithmetic and what I personally enjoyed w...
Please review the code. <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>RGB to HEX (and vice versa) converter</title> <link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.0/normalize.min.css"> <style> body{ color: #222; font-family: "Segoe ...
Is there a better (functional or more idiomatic) way to get the first positive number that is not included in a set? val set = Set(4, 1, 2, 0, 5) var x = 0 while(set(x)) x += 1 println(x) // Should print 3
I have a server application using TcpListener in BackgroundWorker, where my application is doing some work, and in the background listening to a IP:PORT. The DoWork of the BackgroundWorker: private void m_oWorker_DoWork(object sender, DoWorkEventArgs e) { while (true) //infinit loop : listen { var clien...
Could you suggest ways of writing this code better? bool success = true; if(x == 0) { if(do_up) run_do_up(); else if(do_a) run_do_a(); else if(do_n) run_do_n(); else success = false; } else if(x == 1) { if(do_n) run_do_n(); else if(do_a) run_do_a(...
Given a mongodb collection that stores trees as nodes with parent references this methods returns a deep nested tree where every child nodes are stored in a property childs[Seq] def getTree(rootId: BSONObjectID): Future[CategoryTreeNode] = { def collect(parent: CategoryTreeNode): Future[CategoryTreeNode] = { ...
In my latest project I am using fullscreen background images for each page. I decided to write some code to fetch the different thumbnail sizes and then use it as a background for the appropriate viewport size using media queries. I also made sure that in the case of big screens the smallest image loads first so that t...
I need to know whether I am doing the best way of binding click event through elements in jQuery. I need to avoid duplicate code in my function (since lot of duplicate code is repeated in all functions). How can I clean this up and do it in a better way? $(".nna-icon-excel").click(function (e) { var $t...
The code below will split environment variables from a command line (always appear at the end of the command line). Environment variables are represented by '-E key=value'. I've achieved this like so, but I'm wondering if there's a more elegant way public class TestSplit { public static void main(String... args) { ...
I am trying to make a thread test in which 4 threads are all trying to set a bool. Only one should be allowed to set it. After the first thread has set the bool (m_isRunning) to true, no other threads should set it to true because of the check isRunning(). This implementation works, but I wonder if this is the best/mos...
I have recently written the program for the Sherlock and The Beast' HackerRank challenge. That's working fine, but the problem is that it takes too much time if a big number is given as a input. I would like you to help me out in optimizing my code so that it could run under 16 seconds, which is needed. from collectio...
HTML form field names must be equal to SQL table field names. Changing only table name and allowed fields can be used in many other update pages. How can I improve this? $allowed = array("name","surname","email","rank"); $items = ''; foreach($_POST as $key => $value) { if (in_array($key , $allowed)) { $ite...
I'd like some additional assistance on refactoring. This is my latest update for this iteration. #region WMI Classes /// <summary> /// The Win32_OperatingSystem WMI class represents a Windows-based OS installed on a computer. Any OS that can be /// installed on a computer that can run a Windows-based OS is a descende...
I have an Olympics database from each Olympic year and I want to find the person that has won the most medals. The main problem is that I'm basically querying the same sub-query twice in SUBSET1 and SUBSET2. How would I go about making this more efficient? Select athlete FROM ( Select athlete, Sum(total_medals) as to...
I have long been looking for an elegant, one-line solution to map enum to strings automatically, for use with the << and >> stream operators. I know that a lot of macros have been proposed to achieve that, but I never found a really simple scheme, with only one macro call. This is my attempt, and I would be interested ...
The original question where the general concept of this implementation was discussed: Using ID's with a "scope" -like hierarchy I have designed a resource manager as part of a game programming project that I have been working on as a hobby. Implementing as much functionality as possible in the least amount of time and ...
I keep seeing /subsite/../global/css/file.css when I look at my website's source code, and today I decided that I want to get rid of the unnecessary traversal in the path itself, so it becomes /global/css/file.css. I made myself a function which I now use for all paths. Here is the base of my function that accomplishes...
I've built a web site that uses AJAX to update a div. Most of the data displayed in the div is drawn from a MySQL database. All the pages are PHP. I've tried to follow best practices. I put all the query strings into stored procedures in the database. The PHP files call the stored procedures with parameters that JavaS...
I've decided to go with OOP style and prepared statements, and so far I like it a lot more than the procedural style. It's much more understandable in my opinion. For this code review, I've just included my PHP code that interacts with my MySQL database. Everything is working how it should, but I'd like to know if you...
I guess I'm a little late with my entry to this code challenge mentioned here, but I decided the world must need yet another RPSLS implementation to critique. #include <vector> #include <string> #include <iostream> #include <stdlib.h> #include <algorithm> #include <time.h> /* Here are your rules: "Scissors cuts paper,...
My code works, but the aesthetic of the code seems to need some real work. The logic is simple enough: Create three lists of words that will be used throughout the conversion Create three functions: One for sub-1000 conversion Another for 1000-and-up conversion Another function for splitting and storing into a list...
I've got the following Elixir code: defmodule Envvar do def exists?(env) do :os.getenv(env) != false end def get(env) do if exists?(env) do {env, :os.getenv(env)} else {env, nil} end end end Two things: Am I using the ? correctly here? I'm assuming that...
Here's an attempt I've made of implementing the Barnes-Hut n-body algorithm, or its initial stage - The quadtree. That there're lots of lengthy doc strings might excuse the lack of detailed explanation here. My primary concerns as a beginner are to Avoid complexity Avoid library imports Make fast and short code whenev...
Previous version: Updating Grid on Webpage Task: Draw a grid with a given number of rows and columns. Each cell can be any color. The same grid should also be updated at a predetermined time interval. The grid should cover the entire visible portion of the page in the browser. Add a context menu with which you c...
I'd like some advice about any better or cleaner way to implement this class, if there's any. I made it using this answer, posted on Stack Overflow, as reference. A lot of problems arose when I switched C function pointers to std::function due to the lack of the equality operator on it, so I ended up implementing a in...
From Coderbyte: Have the function StringReduction(str) take the str parameter being passed and return the smallest number you can get through the following reduction method. The method is: Only the letters a, b, and c will be given in str and you must take two different adjacent characters and replace it with ...
I have a function that returns the index of the first alphabet letter found in a string, or -1 if no letter is found. It seems like there should be a way to do this with extension methods instead of looping, but I can't think of one: int findFirstLetter(string str) { for(int ctr=0;ctr<str.Length;ctr++) { if (Char....
I am SURE this is somehow easy but reading the docs isn't bringing it to light. The problem: I am trying to setup a JMS message listener and what I need is for the first client to have exclusive message processing rights. That is: Until a single client acknowledges the message the server will not notify any other consu...
I wrote this bit of python intending it to become some module to replace excel mapping programs like MapForce. Right now it only does columns to columns. So the number of rows in always equals the number of rows out. To declare a map, use a python defaultdict(list) object from collections import defaultdict demoCmd =...
I'm working on a CTags plugin for Sublime Text. One of the open issues revolves around the fact that an in-memory sort of a tag file can cause some form of memory or buffer overflow errors (the stack in Sublime Text is limited to ~25 MB apparently). I've devised a simple external bucket sort to resolve this issue: #/us...
I am designing a new application to track sports statistics with code-first migration. I have the bare minimum POCO setup. The problem is that I am not happy with the design specifically how the players, teams and tournaments are relating to each other. I appreciate any comments and suggestions. PlayerAccount class: /...
In my Java code I have these three classes. Basically I have a User class, and also a GUI class that holds TextViews and other things (GUI related) for the properties that show on the screen. The SearchUser is just a object that has the GUI properties. One of these per user object. I noticed that both the user class an...
I've written some code to brute-force enumerate the solution space of nonogram puzzles up to a certain size. It does a good job up to the first ~4 billion puzzles, but I run out of disk space to store any bigger collection of the solution space set. Because of some incredibly interesting patterns within the encoded set...
This should be the last iteration for this code. Does this approach make sense or am I heading down the wrong path? The only thing I can see to make this better is to genericize the GetType methods at the end so that I could eliminate the goofy if statement in the GetProperties method. Any suggestions? What I've don...
Is this class perfect for databases? All I want to know is what I should change to make it perfect. error_reporting(E_ALL); class RESPETO{ private $_server = 'mysql'; private $_host = ''; private $_database = ''; private $db_username = ''; private $db_password = ''; private $db_charset = 'utf8'...
The linked code below is meant to be used in a user space file-system (fuse). Given that multiple processes may have multiple files opened on the file-system, the files on the specific user space file-system will map each of these open files to an (encrypted) file on a regular file-system, attempting to keep all mapped...
How to shorten up this code? I know there's a way that this kind of code could be shortened, but I don't know how by myself yet. Who can help me? //CHOOSE LEVEL: FROZEN case 1213: sendOption5("Level 1 " + (c.achievedFloor <= 1 ? "@gre@(Achieved)" : "@red@(Not achieved)") + "", "Level 2 " + (...
I am having this problem with my code. I have variables firstnumber and secondnumber, as well as operand and result. Then I am using the string.Split to know whether it's an operator or a number. After that I have used a while loop if a.Length is over 2 and if it is, I declared an double numbers which is a[i]. i is 3 ...
I have a C# function like below, and in the else block, the function must return something. I don't know whether returning null is a good practice or not. public Nullable<Point> GetSprite(int x, int y) { if (x <= xCount && y <= yCount) { return new Point(x * spriteHeight, y * spriteWidth); } els...
I just want to know if this is reasonably good implementation of including local/remote JavaScript files. The function takes a dictionary with (string) .src whitespace-separated list of urls to include/execute in global context, and (func) .done/.error/.load callbacks to run in corresponding cases, resolves URLs to a...
I want to divide the screen in two halves. The layout is locked on portrait mode. The top half will have one button and the bottom half will have many buttons. That's why I choose this division, since the top half can be potentially scrollable. This is my layout xml: <LinearLayout xmlns:android="http://schemas.android...
This one review will be a little bit tricky: I was trying to implement a template Vector struct in C11. Of course, templates don't really exist in C11, so I used a few macros to get the desired interface. Here is the implementation of the core features, trying to mimick those of the c++ std::vector. Some are still miss...
As usual, please be brutally honest with your opinion of my code, and how you would judge it if I were to code this at a top-tier tech company for an interview(think Google, MSFT, Facebook, etc). My algorithm is has a worst time complexity of O(n). Question: Given an unsorted integer array, find the first missing posit...
I'm trying to implement a TaskScheduler that runs all tasks in the order they are submitted, on a single dedicated thread. Here's my implementation, using a BlockingCollection: class SequentialScheduler : TaskScheduler, IDisposable { readonly BlockingCollection<Task> m_taskQueue = new BlockingCollection<Task>(); ...
As soon as I saw the First missing positive question, I decided to write my own method for this before writing my review on the question. Judge me by the same standards as bazang wants to be judged, i.e. As if this was written for a big company such as Google for an interview. I wasn't sure how the input 7, 8, 9 should...
After spending a few ages writing out every combination of triggers, bindings and storyboards, I finally managed to get my program working. First time working with WPF, so I made a big mess. Now it's time to put on my refactoring hat and make the code neat and proper again! That is, if I knew how. Could anyone experien...
I've done a library that can parse strings to different java types and to List<...>, Set<...>, Map<...> and arrays of such types. Below are some usage examples, to get a better understanding where to start reviewing: StringToTypeParser parser = StringToTypeParser.newBuilder().build(); Integer i = parser.parse("1", Int...
I'm a F# newbie, and would like to share my implementation of the Poker Hands Kata problem to get some feedback. module PokerHands open System.Text.RegularExpressions type Figure = | Two | Three | Four | Five | Six | Seven | Eight | Nine | Ten | Jack | Queen | King | Ace type Suit = Diamonds | Sp...
I really do not have access to anyone, outside of professors, that is highly knowledgeable about Java so I figured I would post my stuff here to further my knowledge and improve my coding. This is homework for my Operating Systems class and it works. Here are some of my main concerns. Is this a good use of the sta...
I have some code that I'd written using this pattern with Step.js. In this case, talking to MongoDB in Node: Step( function connectToDatabaseWithAuthorization() { mongodb.connect(mongoConnectURI, this); }, function getCommitCollection(err, conn) { if (err) handleResErr(res, err); ...
Given an input string, reverse the string word by word. For example: Given s = "the sky is blue", return "blue is sky the". What constitutes a word? A sequence of non-space characters constitutes a word. Could the input string contain leading or trailing spaces? Yes. However, your reversed string should not contain...
I have the following two vectors in C++11: vector<unsigned char> left = { 1, 2, 3, 4, 5, 6 }; // it is meant to represent the number: 123456 vector<unsigned char> right = { 1, 2, 3, 4 }; // meant to be number: 1234 After a function processes them, they become: left = { 6, 5, 4, 3, 2, 1 }; right = { 4, 3, 2, 1 }; Now,...
Please review this code: function toggleFullScreen() { if (!document.fullscreenElement && !document.mozFullScreenElement && !document.webkitFullscreenElement && !document.msFullscreenElement) { var elem = document.documentElement; if (elem.requestFullscreen) { elem.requestFullscreen(); } e...
I solved this problem in about 11 minutes (with all 50+ test cases passed). I think most of you already know me by now, and I truly appreciate your advice, but please be brutal and judge me as if I was being interviewed by you. Question: Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do ...