We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
According to me there are several things wrong in this logic.
First of all, !(NOT) is a LOGICAL operator.. not a binary one. NOT of any non zero argument will return 0 and the NOT of 0 ie !0 = 1
Secondly, the problem with unsigned is that the code includes a -INF hence your INF should only be set to the highest number possible in signed int. According to me this will be the best
#define INF (1<<31)-1
which is equal to 2147483647
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Preprocessor Solution
You are viewing a single comment's thread. Return to all comments →
According to me there are several things wrong in this logic. First of all, !(NOT) is a LOGICAL operator.. not a binary one. NOT of any non zero argument will return 0 and the NOT of 0 ie !0 = 1
Secondly, the problem with unsigned is that the code includes a -INF hence your INF should only be set to the highest number possible in signed int. According to me this will be the best
#define INF (1<<31)-1which is equal to 2147483647